feat(call): gallery pages to page through in large meetings
- Page 1 holds the own tile and the speakers, later pages 9 people each; the +N tile is gone from the gallery - A "< 1 / 3 >" pager under the grid turns the pages; video is only asked for the shown page - Speaker view keeps its +N tile in the filmstrip - Test for chat switching follows the call window (the call stays shown) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -18,7 +18,9 @@ use super::health::{HealthBanner, HealthState};
18
18
use super::bubbles::ChatBubble;
19
19
use super::fullscreen::FullscreenState;
20
20
use super::pictures::CallPictures;
21
use super::stage_layout::{FILMSTRIP_MAX, GALLERY_MAX, RECENT_SPEAKER, SPEAKER_HOLD, VisibleRotation, split_overflow};
21
use super::stage_layout::{
22
FILMSTRIP_MAX, RECENT_SPEAKER, SPEAKER_HOLD, VisibleRotation, first_page_size, split_overflow,
23
};
22
24
use super::transcript::{Transcript, TranscriptEntry};
23
25
use super::view_settings::{CallLayout, ViewSettings};
24
26
use super::options_dialog::OptionsDialog;
@@ -331,6 +333,7 @@ pub struct CallModel {
331
333
reaction_serial: u64,
332
334
pub meeting_chat: Option<String>,
333
335
pub view: ViewSettings,
336
pub gallery_page: usize,
334
337
rotation: VisibleRotation,
335
338
stage_speaker: Option<String>,
336
339
recent_speakers: Vec<String>,
@@ -400,6 +403,7 @@ impl CallModel {
400
403
reaction_serial: 0,
401
404
meeting_chat: None,
402
405
view: ViewSettings::default(),
406
gallery_page: 0,
403
407
rotation: VisibleRotation::default(),
404
408
stage_speaker: None,
405
409
recent_speakers: Vec::new(),
@@ -993,7 +997,7 @@ impl CallModel {
993
997
let cells = match self.effective_layout() {
994
998
_ if self.has_content() => return others,
995
999
CallLayout::Speaker => FILMSTRIP_MAX,
996
CallLayout::Gallery | CallLayout::Content => GALLERY_MAX,
1000
CallLayout::Gallery | CallLayout::Content => return first_page_size(others, self.own_cells()),
997
1001
};
998
1002
split_overflow(others, self.own_cells(), cells).shown
999
1003
}
@@ -1678,8 +1682,8 @@ mod tests {
1678
1682
#[test]
1679
1683
fn a_pinned_person_outside_the_grid_moves_into_it() {
1680
1684
let mut model = crowd(12);
1681
let grid = split_overflow(12, 1, GALLERY_MAX).shown;
1682
assert_eq!(grid, 7);
1685
let grid = first_page_size(12, 1);
1686
assert_eq!(grid, 8);
1683
1687
assert!(!shown_mris(&model)[..grid].contains(&"8:orgid:p11".to_owned()));
1684
1688
model.toggle_pin("8:orgid:p11");
1685
1689
assert!(shown_mris(&model)[..grid].contains(&"8:orgid:p11".to_owned()));
@@ -1692,7 +1696,7 @@ mod tests {
1692
1696
assert_eq!(model.own_cells(), 1);
1693
1697
model.view.hide_me = true;
1694
1698
assert_eq!(model.own_cells(), 0);
1695
assert_eq!(split_overflow(12, model.own_cells(), GALLERY_MAX).shown, 8);
1699
assert_eq!(first_page_size(12, model.own_cells()), 9);
1696
1700
}
1697
1701
1698
1702
#[test]
@@ -18,7 +18,9 @@ use super::health::{HealthBanner, HealthState};18
use super::bubbles::ChatBubble;18
use super::bubbles::ChatBubble;19
use super::fullscreen::FullscreenState;19
use super::fullscreen::FullscreenState;20
use super::pictures::CallPictures;20
use super::pictures::CallPictures;21
use super::stage_layout::{FILMSTRIP_MAX, GALLERY_MAX, RECENT_SPEAKER, SPEAKER_HOLD, VisibleRotation, split_overflow};21
use super::stage_layout::{22
FILMSTRIP_MAX, RECENT_SPEAKER, SPEAKER_HOLD, VisibleRotation, first_page_size, split_overflow,23
};22
use super::transcript::{Transcript, TranscriptEntry};24
use super::transcript::{Transcript, TranscriptEntry};23
use super::view_settings::{CallLayout, ViewSettings};25
use super::view_settings::{CallLayout, ViewSettings};24
use super::options_dialog::OptionsDialog;26
use super::options_dialog::OptionsDialog;@@ -331,6 +333,7 @@ pub struct CallModel {331
reaction_serial: u64,333
reaction_serial: u64,332
pub meeting_chat: Option<String>,334
pub meeting_chat: Option<String>,333
pub view: ViewSettings,335
pub view: ViewSettings,336
pub gallery_page: usize,334
rotation: VisibleRotation,337
rotation: VisibleRotation,335
stage_speaker: Option<String>,338
stage_speaker: Option<String>,336
recent_speakers: Vec<String>,339
recent_speakers: Vec<String>,@@ -400,6 +403,7 @@ impl CallModel {400
reaction_serial: 0,403
reaction_serial: 0,401
meeting_chat: None,404
meeting_chat: None,402
view: ViewSettings::default(),405
view: ViewSettings::default(),406
gallery_page: 0,403
rotation: VisibleRotation::default(),407
rotation: VisibleRotation::default(),404
stage_speaker: None,408
stage_speaker: None,405
recent_speakers: Vec::new(),409
recent_speakers: Vec::new(),@@ -993,7 +997,7 @@ impl CallModel {993
let cells = match self.effective_layout() {997
let cells = match self.effective_layout() {994
_ if self.has_content() => return others,998
_ if self.has_content() => return others,995
CallLayout::Speaker => FILMSTRIP_MAX,999
CallLayout::Speaker => FILMSTRIP_MAX,996
CallLayout::Gallery | CallLayout::Content => GALLERY_MAX,1000
CallLayout::Gallery | CallLayout::Content => return first_page_size(others, self.own_cells()),997
};1001
};998
split_overflow(others, self.own_cells(), cells).shown1002
split_overflow(others, self.own_cells(), cells).shown999
}1003
}@@ -1678,8 +1682,8 @@ mod tests {1678
#[test]1682
#[test]1679
fn a_pinned_person_outside_the_grid_moves_into_it() {1683
fn a_pinned_person_outside_the_grid_moves_into_it() {1680
let mut model = crowd(12);1684
let mut model = crowd(12);1681
let grid = split_overflow(12, 1, GALLERY_MAX).shown;1685
let grid = first_page_size(12, 1);1682
assert_eq!(grid, 7);1686
assert_eq!(grid, 8);1683
assert!(!shown_mris(&model)[..grid].contains(&"8:orgid:p11".to_owned()));1687
assert!(!shown_mris(&model)[..grid].contains(&"8:orgid:p11".to_owned()));1684
model.toggle_pin("8:orgid:p11");1688
model.toggle_pin("8:orgid:p11");1685
assert!(shown_mris(&model)[..grid].contains(&"8:orgid:p11".to_owned()));1689
assert!(shown_mris(&model)[..grid].contains(&"8:orgid:p11".to_owned()));@@ -1692,7 +1696,7 @@ mod tests {1692
assert_eq!(model.own_cells(), 1);1696
assert_eq!(model.own_cells(), 1);1693
model.view.hide_me = true;1697
model.view.hide_me = true;1694
assert_eq!(model.own_cells(), 0);1698
assert_eq!(model.own_cells(), 0);1695
assert_eq!(split_overflow(12, model.own_cells(), GALLERY_MAX).shown, 8);1699
assert_eq!(first_page_size(12, model.own_cells()), 9);1696
}1700
}1697
1701
1698
#[test]1702
#[test]@@ -64,6 +64,25 @@ pub fn split_overflow(others: usize, own_cells: usize, capacity: usize) -> Overf
64
64
}
65
65
}
66
66
67
/// The first gallery page holds the own tile and the speakers; later pages hold the rest, a full grid each, like Teams.
68
pub fn first_page_size(others: usize, own_cells: usize) -> usize {
69
others.min(GALLERY_MAX.saturating_sub(own_cells).max(1))
70
}
71
72
pub fn gallery_pages(others: usize, own_cells: usize) -> usize {
73
let rest = others - first_page_size(others, own_cells);
74
1 + rest.div_ceil(GALLERY_MAX)
75
}
76
77
pub fn gallery_page_range(others: usize, own_cells: usize, page: usize) -> std::ops::Range<usize> {
78
let first = first_page_size(others, own_cells);
79
if page == 0 {
80
return 0..first;
81
}
82
let start = (first + (page - 1) * GALLERY_MAX).min(others);
83
start..(start + GALLERY_MAX).min(others)
84
}
85
67
86
#[derive(Debug, Clone, Copy, PartialEq)]
68
87
pub struct Filmstrip {
69
88
pub tile_width: f32,
@@ -370,6 +389,19 @@ mod tests {
370
389
assert!((grid.tile_width / grid.tile_height - 16. / 9.).abs() < 0.001);
371
390
}
372
391
392
#[test]
393
fn a_big_gallery_pages_through_everyone_once() {
394
assert_eq!(gallery_pages(8, 1), 1);
395
assert_eq!(gallery_pages(9, 1), 2);
396
assert_eq!(gallery_pages(9, 0), 1);
397
assert_eq!(gallery_pages(26, 1), 3);
398
assert_eq!(gallery_page_range(26, 1, 0), 0..8);
399
assert_eq!(gallery_page_range(26, 1, 1), 8..17);
400
assert_eq!(gallery_page_range(26, 1, 2), 17..26);
401
assert_eq!(gallery_page_range(0, 1, 0), 0..0);
402
assert_eq!(gallery_pages(0, 1), 1);
403
}
404
373
405
#[test]
374
406
fn nine_people_fit_and_ten_end_in_a_plus_tile() {
375
407
assert_eq!(
@@ -64,6 +64,25 @@ pub fn split_overflow(others: usize, own_cells: usize, capacity: usize) -> Overf64
}64
}65
}65
}66
66
67
/// The first gallery page holds the own tile and the speakers; later pages hold the rest, a full grid each, like Teams.68
pub fn first_page_size(others: usize, own_cells: usize) -> usize {69
others.min(GALLERY_MAX.saturating_sub(own_cells).max(1))70
}71
72
pub fn gallery_pages(others: usize, own_cells: usize) -> usize {73
let rest = others - first_page_size(others, own_cells);74
1 + rest.div_ceil(GALLERY_MAX)75
}76
77
pub fn gallery_page_range(others: usize, own_cells: usize, page: usize) -> std::ops::Range<usize> {78
let first = first_page_size(others, own_cells);79
if page == 0 {80
return 0..first;81
}82
let start = (first + (page - 1) * GALLERY_MAX).min(others);83
start..(start + GALLERY_MAX).min(others)84
}85
67
#[derive(Debug, Clone, Copy, PartialEq)]86
#[derive(Debug, Clone, Copy, PartialEq)]68
pub struct Filmstrip {87
pub struct Filmstrip {69
pub tile_width: f32,88
pub tile_width: f32,@@ -370,6 +389,19 @@ mod tests {370
assert!((grid.tile_width / grid.tile_height - 16. / 9.).abs() < 0.001);389
assert!((grid.tile_width / grid.tile_height - 16. / 9.).abs() < 0.001);371
}390
}372
391
392
#[test]393
fn a_big_gallery_pages_through_everyone_once() {394
assert_eq!(gallery_pages(8, 1), 1);395
assert_eq!(gallery_pages(9, 1), 2);396
assert_eq!(gallery_pages(9, 0), 1);397
assert_eq!(gallery_pages(26, 1), 3);398
assert_eq!(gallery_page_range(26, 1, 0), 0..8);399
assert_eq!(gallery_page_range(26, 1, 1), 8..17);400
assert_eq!(gallery_page_range(26, 1, 2), 17..26);401
assert_eq!(gallery_page_range(0, 1, 0), 0..0);402
assert_eq!(gallery_pages(0, 1), 1);403
}404
373
#[test]405
#[test]374
fn nine_people_fit_and_ten_end_in_a_plus_tile() {406
fn nine_people_fit_and_ten_end_in_a_plus_tile() {375
assert_eq!(407
assert_eq!(@@ -2,7 +2,7 @@ use calling::{TileDetail, VideoWant};
2
2
3
3
use crate::model::{ActiveCall, CallModel, Focus, Tile};
4
4
use crate::stage_layout::{
5
FILMSTRIP_MAX, Filmstrip, GALLERY_MAX, Overflow, filmstrip, share_strip, split_overflow,
5
FILMSTRIP_MAX, Filmstrip, filmstrip, gallery_page_range, gallery_pages, share_strip,
6
6
};
7
7
use crate::view_settings::CallLayout;
8
8
@@ -20,10 +20,25 @@ pub fn measured_stage(call: &ActiveCall) -> (f32, f32) {
20
20
(width, height)
21
21
}
22
22
23
pub fn gallery_split(model: &CallModel) -> (Vec<&Tile>, Overflow) {
23
pub struct GalleryPage<'a> {
24
pub tiles: Vec<&'a Tile>,
25
pub own: bool,
26
pub page: usize,
27
pub pages: usize,
28
}
29
30
pub fn gallery_page(model: &CallModel) -> GalleryPage<'_> {
24
31
let others = model.layout_tiles();
25
let overflow = split_overflow(others.len(), model.own_cells(), GALLERY_MAX);
26
(others, overflow)
32
let own_cells = model.own_cells();
33
let pages = gallery_pages(others.len(), own_cells);
34
let page = model.gallery_page.min(pages - 1);
35
let range = gallery_page_range(others.len(), own_cells, page);
36
GalleryPage {
37
tiles: others[range].to_vec(),
38
own: own_cells > 0 && page == 0,
39
page,
40
pages,
41
}
27
42
}
28
43
29
44
pub struct SpeakerSplit<'a> {
@@ -100,9 +115,9 @@ pub fn video_wants(model: &CallModel, stage: (f32, f32), strip_width: f32) -> Ve
100
115
.chain(split.others[..split.plan.overflow.shown].iter().map(|tile| want(tile, TileDetail::Small)))
101
116
.collect();
102
117
}
103
let (others, overflow) = gallery_split(model);
104
let detail = if overflow.shown <= LARGE_GALLERY_TILES { TileDetail::Stage } else { TileDetail::Small };
105
others[..overflow.shown].iter().map(|tile| want(tile, detail)).collect()
118
let page = gallery_page(model);
119
let detail = if page.tiles.len() <= LARGE_GALLERY_TILES { TileDetail::Stage } else { TileDetail::Small };
120
page.tiles.iter().map(|tile| want(tile, detail)).collect()
106
121
}
107
122
108
123
#[cfg(test)]
@@ -114,7 +129,7 @@ mod tests {
114
129
use super::{FILMSTRIP_TILE_MAX, GRID_PADDING, TILE_GAP, video_wants};
115
130
use crate::model::CallModel;
116
131
use crate::share_view::STRIP_DEFAULT_WIDTH;
117
use crate::stage_layout::{GALLERY_MAX, filmstrip, split_overflow};
132
use crate::stage_layout::{filmstrip, first_page_size};
118
133
use crate::view_settings::CallLayout;
119
134
120
135
const STAGE: (f32, f32) = (1400., 800.);
@@ -158,10 +173,10 @@ mod tests {
158
173
}
159
174
160
175
#[test]
161
fn a_big_gallery_asks_for_small_pictures_and_skips_the_plus_n_people() {
176
fn a_big_gallery_asks_for_small_pictures_and_skips_the_other_pages() {
162
177
let model = crowd(14);
163
178
let wants = video_wants(&model, STAGE, STRIP_DEFAULT_WIDTH);
164
assert_eq!(wants.len(), split_overflow(14, 1, GALLERY_MAX).shown);
179
assert_eq!(wants.len(), first_page_size(14, 1));
165
180
assert!(details(&wants).iter().all(|detail| *detail == TileDetail::Small));
166
181
let hidden: Vec<&str> = model.layout_tiles()[wants.len()..].iter().map(|tile| tile.mri.as_str()).collect();
167
182
assert!(wants.iter().all(|want| !hidden.contains(&want.mri.as_str())));
@@ -2,7 +2,7 @@ use calling::{TileDetail, VideoWant};2
2
3
use crate::model::{ActiveCall, CallModel, Focus, Tile};3
use crate::model::{ActiveCall, CallModel, Focus, Tile};4
use crate::stage_layout::{4
use crate::stage_layout::{5
FILMSTRIP_MAX, Filmstrip, GALLERY_MAX, Overflow, filmstrip, share_strip, split_overflow,5
FILMSTRIP_MAX, Filmstrip, filmstrip, gallery_page_range, gallery_pages, share_strip,6
};6
};7
use crate::view_settings::CallLayout;7
use crate::view_settings::CallLayout;8
8
@@ -20,10 +20,25 @@ pub fn measured_stage(call: &ActiveCall) -> (f32, f32) {20
(width, height)20
(width, height)21
}21
}22
22
23
pub fn gallery_split(model: &CallModel) -> (Vec<&Tile>, Overflow) {23
pub struct GalleryPage<'a> {24
pub tiles: Vec<&'a Tile>,25
pub own: bool,26
pub page: usize,27
pub pages: usize,28
}29
30
pub fn gallery_page(model: &CallModel) -> GalleryPage<'_> {24
let others = model.layout_tiles();31
let others = model.layout_tiles();25
let overflow = split_overflow(others.len(), model.own_cells(), GALLERY_MAX);32
let own_cells = model.own_cells();26
(others, overflow)33
let pages = gallery_pages(others.len(), own_cells);34
let page = model.gallery_page.min(pages - 1);35
let range = gallery_page_range(others.len(), own_cells, page);36
GalleryPage {37
tiles: others[range].to_vec(),38
own: own_cells > 0 && page == 0,39
page,40
pages,41
}27
}42
}28
43
29
pub struct SpeakerSplit<'a> {44
pub struct SpeakerSplit<'a> {@@ -100,9 +115,9 @@ pub fn video_wants(model: &CallModel, stage: (f32, f32), strip_width: f32) -> Ve100
.chain(split.others[..split.plan.overflow.shown].iter().map(|tile| want(tile, TileDetail::Small)))115
.chain(split.others[..split.plan.overflow.shown].iter().map(|tile| want(tile, TileDetail::Small)))101
.collect();116
.collect();102
}117
}103
let (others, overflow) = gallery_split(model);118
let page = gallery_page(model);104
let detail = if overflow.shown <= LARGE_GALLERY_TILES { TileDetail::Stage } else { TileDetail::Small };119
let detail = if page.tiles.len() <= LARGE_GALLERY_TILES { TileDetail::Stage } else { TileDetail::Small };105
others[..overflow.shown].iter().map(|tile| want(tile, detail)).collect()120
page.tiles.iter().map(|tile| want(tile, detail)).collect()106
}121
}107
122
108
#[cfg(test)]123
#[cfg(test)]@@ -114,7 +129,7 @@ mod tests {114
use super::{FILMSTRIP_TILE_MAX, GRID_PADDING, TILE_GAP, video_wants};129
use super::{FILMSTRIP_TILE_MAX, GRID_PADDING, TILE_GAP, video_wants};115
use crate::model::CallModel;130
use crate::model::CallModel;116
use crate::share_view::STRIP_DEFAULT_WIDTH;131
use crate::share_view::STRIP_DEFAULT_WIDTH;117
use crate::stage_layout::{GALLERY_MAX, filmstrip, split_overflow};132
use crate::stage_layout::{filmstrip, first_page_size};118
use crate::view_settings::CallLayout;133
use crate::view_settings::CallLayout;119
134
120
const STAGE: (f32, f32) = (1400., 800.);135
const STAGE: (f32, f32) = (1400., 800.);@@ -158,10 +173,10 @@ mod tests {158
}173
}159
174
160
#[test]175
#[test]161
fn a_big_gallery_asks_for_small_pictures_and_skips_the_plus_n_people() {176
fn a_big_gallery_asks_for_small_pictures_and_skips_the_other_pages() {162
let model = crowd(14);177
let model = crowd(14);163
let wants = video_wants(&model, STAGE, STRIP_DEFAULT_WIDTH);178
let wants = video_wants(&model, STAGE, STRIP_DEFAULT_WIDTH);164
assert_eq!(wants.len(), split_overflow(14, 1, GALLERY_MAX).shown);179
assert_eq!(wants.len(), first_page_size(14, 1));165
assert!(details(&wants).iter().all(|detail| *detail == TileDetail::Small));180
assert!(details(&wants).iter().all(|detail| *detail == TileDetail::Small));166
let hidden: Vec<&str> = model.layout_tiles()[wants.len()..].iter().map(|tile| tile.mri.as_str()).collect();181
let hidden: Vec<&str> = model.layout_tiles()[wants.len()..].iter().map(|tile| tile.mri.as_str()).collect();167
assert!(wants.iter().all(|want| !hidden.contains(&want.mri.as_str())));182
assert!(wants.iter().all(|want| !hidden.contains(&want.mri.as_str())));@@ -2389,14 +2389,12 @@ mod tests {
2389
2389
}
2390
2390
2391
2391
#[gpui_kit::test]
2392
fn picking_another_chat_moves_the_call_to_the_mini_window(cx: &mut TestAppContext) {
2392
fn picking_another_chat_keeps_the_call_window_showing_the_call(cx: &mut TestAppContext) {
2393
2393
let app = app_with_call(cx);
2394
2394
cx.update(|cx| {
2395
2395
app.update(cx, |state, cx| {
2396
2396
assert!(state.viewing_call());
2397
2397
state.select(Selection::Chat("c1".into()), cx);
2398
assert!(!state.viewing_call());
2399
state.show_call(true, cx);
2400
2398
assert!(state.viewing_call());
2401
2399
})
2402
2400
});
@@ -2389,14 +2389,12 @@ mod tests {2389
}2389
}2390
2390
2391
#[gpui_kit::test]2391
#[gpui_kit::test]2392
fn picking_another_chat_moves_the_call_to_the_mini_window(cx: &mut TestAppContext) {2392
fn picking_another_chat_keeps_the_call_window_showing_the_call(cx: &mut TestAppContext) {2393
let app = app_with_call(cx);2393
let app = app_with_call(cx);2394
cx.update(|cx| {2394
cx.update(|cx| {2395
app.update(cx, |state, cx| {2395
app.update(cx, |state, cx| {2396
assert!(state.viewing_call());2396
assert!(state.viewing_call());2397
state.select(Selection::Chat("c1".into()), cx);2397
state.select(Selection::Chat("c1".into()), cx);2398
assert!(!state.viewing_call());2399
state.show_call(true, cx);2400
assert!(state.viewing_call());2398
assert!(state.viewing_call());2401
})2399
})2402
});2400
});@@ -62,7 +62,7 @@ pub use preview::{CameraPreview, preview_backgrounds};
62
62
pub use reminder::{MeetingToasts, ReminderPhase, subtitle as meeting_subtitle};
63
63
pub use ring::{MissedCall, RingEntry, Rings};
64
64
pub use stage_split::{
65
GRID_PADDING, STRIP_GAP, SpeakerSplit, StripSplit, TILE_GAP, gallery_split,
65
GRID_PADDING, STRIP_GAP, GalleryPage, SpeakerSplit, StripSplit, TILE_GAP, gallery_page,
66
66
measured_stage, speaker_split, strip_split, video_wants,
67
67
};
68
68
pub use stage_layout::{contain_size, focus_stage_size, gallery_grid};
@@ -62,7 +62,7 @@ pub use preview::{CameraPreview, preview_backgrounds};62
pub use reminder::{MeetingToasts, ReminderPhase, subtitle as meeting_subtitle};62
pub use reminder::{MeetingToasts, ReminderPhase, subtitle as meeting_subtitle};63
pub use ring::{MissedCall, RingEntry, Rings};63
pub use ring::{MissedCall, RingEntry, Rings};64
pub use stage_split::{64
pub use stage_split::{65
GRID_PADDING, STRIP_GAP, SpeakerSplit, StripSplit, TILE_GAP, gallery_split,65
GRID_PADDING, STRIP_GAP, GalleryPage, SpeakerSplit, StripSplit, TILE_GAP, gallery_page,66
measured_stage, speaker_split, strip_split, video_wants,66
measured_stage, speaker_split, strip_split, video_wants,67
};67
};68
pub use stage_layout::{contain_size, focus_stage_size, gallery_grid};68
pub use stage_layout::{contain_size, focus_stage_size, gallery_grid};@@ -4,7 +4,7 @@ use calling::CallCommand;
4
4
use gpui_kit::*;
5
5
6
6
use super::caption_style::{CaptionPosition, CaptionSize};
7
use super::{measured_stage, video_wants};
7
use super::{gallery_page, measured_stage, video_wants};
8
8
use super::bubbles::{BUBBLE_SHOWN, ChatBubble, push_bubble};
9
9
use super::fullscreen::{FullscreenState, HINT_SHOWN};
10
10
use super::view_settings::{CallLayout, ViewSettings};
@@ -42,6 +42,21 @@ impl AppState {
42
42
self.change_call_view(|view| view.choose(layout), cx);
43
43
}
44
44
45
pub fn turn_call_gallery_page(&mut self, forward: bool, cx: &mut Context<Self>) {
46
let Some(call) = self.call.as_mut() else {
47
return;
48
};
49
let pages = gallery_page(&call.model).pages;
50
let page = call.model.gallery_page.min(pages - 1);
51
call.model.gallery_page = if forward {
52
(page + 1).min(pages - 1)
53
} else {
54
page.saturating_sub(1)
55
};
56
self.sync_video_wants();
57
cx.notify();
58
}
59
45
60
pub fn toggle_call_hide_no_video(&mut self, cx: &mut Context<Self>) {
46
61
self.change_call_view(|view| view.hide_no_video = !view.hide_no_video, cx);
47
62
}
@@ -4,7 +4,7 @@ use calling::CallCommand;4
use gpui_kit::*;4
use gpui_kit::*;5
5
6
use super::caption_style::{CaptionPosition, CaptionSize};6
use super::caption_style::{CaptionPosition, CaptionSize};7
use super::{measured_stage, video_wants};7
use super::{gallery_page, measured_stage, video_wants};8
use super::bubbles::{BUBBLE_SHOWN, ChatBubble, push_bubble};8
use super::bubbles::{BUBBLE_SHOWN, ChatBubble, push_bubble};9
use super::fullscreen::{FullscreenState, HINT_SHOWN};9
use super::fullscreen::{FullscreenState, HINT_SHOWN};10
use super::view_settings::{CallLayout, ViewSettings};10
use super::view_settings::{CallLayout, ViewSettings};@@ -42,6 +42,21 @@ impl AppState {42
self.change_call_view(|view| view.choose(layout), cx);42
self.change_call_view(|view| view.choose(layout), cx);43
}43
}44
44
45
pub fn turn_call_gallery_page(&mut self, forward: bool, cx: &mut Context<Self>) {46
let Some(call) = self.call.as_mut() else {47
return;48
};49
let pages = gallery_page(&call.model).pages;50
let page = call.model.gallery_page.min(pages - 1);51
call.model.gallery_page = if forward {52
(page + 1).min(pages - 1)53
} else {54
page.saturating_sub(1)55
};56
self.sync_video_wants();57
cx.notify();58
}59
45
pub fn toggle_call_hide_no_video(&mut self, cx: &mut Context<Self>) {60
pub fn toggle_call_hide_no_video(&mut self, cx: &mut Context<Self>) {46
self.change_call_view(|view| view.hide_no_video = !view.hide_no_video, cx);61
self.change_call_view(|view| view.hide_no_video = !view.hide_no_video, cx);47
}62
}@@ -19,7 +19,7 @@ use super::widgets::icon;
19
19
use crate::app_state::AppState;
20
20
use crate::call::{
21
21
ActiveCall, CallLayout, CallModel, GRID_PADDING, STRIP_GAP, SpeakerSplit,
22
StripSplit, TILE_GAP, Tile, TileSize, focus_stage_size, gallery_grid, gallery_split,
22
StripSplit, TILE_GAP, Tile, TileSize, focus_stage_size, gallery_grid, gallery_page,
23
23
measured_stage, shown_bubbles, speaker_split, strip_split,
24
24
};
25
25
use crate::theme;
@@ -42,6 +42,10 @@ const BUBBLE_FADE_FROM: f32 = 0.9;
42
42
const BUBBLE_BACKGROUND: f32 = 0.72;
43
43
const CHIP_BACKGROUND: f32 = 0.6;
44
44
pub const FULLSCREEN_HINT: &str = "Press Esc to exit full screen";
45
pub const GALLERY_PAGER_TAG: &str = "shell/islands/main/call-stage/pager";
46
const PAGER_HEIGHT: f32 = 32.;
47
const PAGER_BUTTON: f32 = 28.;
48
const PAGER_ICON: f32 = 16.;
45
49
46
50
fn measure_stage(call: &ActiveCall) -> impl IntoElement {
47
51
let stage_size = call.stage_size.clone();
@@ -350,6 +354,58 @@ fn rows_of(cells: Vec<AnyElement>, columns: usize) -> Vec<Div> {
350
354
}
351
355
}
352
356
357
fn pager_button(
358
app: &Entity<AppState>,
359
id: &'static str,
360
glyph: IconName,
361
tooltip: &'static str,
362
forward: bool,
363
enabled: bool,
364
) -> AnyElement {
365
let app = app.clone();
366
let color = if enabled { theme::text() } else { theme::text_faint() };
367
div()
368
.id(id)
369
.size(px(PAGER_BUTTON))
370
.flex()
371
.items_center()
372
.justify_center()
373
.rounded_full()
374
.child(icon(glyph, PAGER_ICON, color))
375
.when(enabled, |button| {
376
button
377
.cursor_pointer()
378
.hover(|button| button.bg(theme::row_hover()))
379
.tooltip(move |window, cx| Tooltip::new(tooltip).build(window, cx))
380
.on_click(move |_, _, cx| {
381
app.update(cx, |state, cx| state.turn_call_gallery_page(forward, cx));
382
})
383
})
384
.into_any_element()
385
}
386
387
fn gallery_pager(app: &Entity<AppState>, page: usize, pages: usize) -> AnyElement {
388
h_flex()
389
.debug_selector(|| GALLERY_PAGER_TAG.into())
390
.h(px(PAGER_HEIGHT))
391
.px(px(2.))
392
.gap(px(4.))
393
.items_center()
394
.rounded_full()
395
.bg(theme::row_hover())
396
.child(pager_button(app, "call-gallery-previous", IconName::ChevronLeft, "Previous page", false, page > 0))
397
.child(
398
div()
399
.min_w(px(40.))
400
.text_center()
401
.text_size(px(12.))
402
.text_color(theme::text_soft())
403
.child(format!("{} / {}", page + 1, pages)),
404
)
405
.child(pager_button(app, "call-gallery-next", IconName::ChevronRight, "Next page", true, page + 1 < pages))
406
.into_any_element()
407
}
408
353
409
fn gallery_body(
354
410
app: &Entity<AppState>,
355
411
state: &AppState,
@@ -357,30 +413,28 @@ fn gallery_body(
357
413
now: Instant,
358
414
stage: (f32, f32),
359
415
) -> AnyElement {
360
let (others, overflow) = gallery_split(model);
361
let own_cells = model.own_cells();
362
let cells = overflow.shown + own_cells + usize::from(overflow.hidden > 0);
416
let page = gallery_page(model);
417
let paged = page.pages > 1;
418
let pager_room = if paged { PAGER_HEIGHT + TILE_GAP } else { 0. };
419
let cells = page.tiles.len() + usize::from(page.own);
363
420
let grid = gallery_grid(
364
421
cells,
365
422
stage.0 - 2. * GRID_PADDING,
366
stage.1 - 2. * GRID_PADDING,
423
stage.1 - 2. * GRID_PADDING - pager_room,
367
424
TILE_GAP,
368
425
);
369
426
let size = TileSize::sixteen_by_nine(grid.tile_width.floor());
370
let shown = &others[..overflow.shown];
371
let mut tiles: Vec<AnyElement> = shown
427
let mut tiles: Vec<AnyElement> = page
428
.tiles
372
429
.iter()
373
430
.map(|tile| person_tile(app, state, model, tile, size, now))
374
431
.collect();
375
if own_cells > 0 {
432
if page.own {
376
433
tiles.insert(
377
own_slot(model, shown),
434
own_slot(model, &page.tiles),
378
435
own_tile(app, state, model, size, now),
379
436
);
380
437
}
381
if overflow.hidden > 0 {
382
tiles.push(overflow_tile(app, state, size, &others[overflow.shown..]));
383
}
384
438
v_flex()
385
439
.absolute()
386
440
.inset_0()
@@ -388,6 +442,7 @@ fn gallery_body(
388
442
.justify_center()
389
443
.gap(px(TILE_GAP))
390
444
.children(rows_of(tiles, grid.columns))
445
.when(paged, |body| body.child(gallery_pager(app, page.page, page.pages)))
391
446
.into_any_element()
392
447
}
393
448
@@ -19,7 +19,7 @@ use super::widgets::icon;19
use crate::app_state::AppState;19
use crate::app_state::AppState;20
use crate::call::{20
use crate::call::{21
ActiveCall, CallLayout, CallModel, GRID_PADDING, STRIP_GAP, SpeakerSplit,21
ActiveCall, CallLayout, CallModel, GRID_PADDING, STRIP_GAP, SpeakerSplit,22
StripSplit, TILE_GAP, Tile, TileSize, focus_stage_size, gallery_grid, gallery_split,22
StripSplit, TILE_GAP, Tile, TileSize, focus_stage_size, gallery_grid, gallery_page,23
measured_stage, shown_bubbles, speaker_split, strip_split,23
measured_stage, shown_bubbles, speaker_split, strip_split,24
};24
};25
use crate::theme;25
use crate::theme;@@ -42,6 +42,10 @@ const BUBBLE_FADE_FROM: f32 = 0.9;42
const BUBBLE_BACKGROUND: f32 = 0.72;42
const BUBBLE_BACKGROUND: f32 = 0.72;43
const CHIP_BACKGROUND: f32 = 0.6;43
const CHIP_BACKGROUND: f32 = 0.6;44
pub const FULLSCREEN_HINT: &str = "Press Esc to exit full screen";44
pub const FULLSCREEN_HINT: &str = "Press Esc to exit full screen";45
pub const GALLERY_PAGER_TAG: &str = "shell/islands/main/call-stage/pager";46
const PAGER_HEIGHT: f32 = 32.;47
const PAGER_BUTTON: f32 = 28.;48
const PAGER_ICON: f32 = 16.;45
49
46
fn measure_stage(call: &ActiveCall) -> impl IntoElement {50
fn measure_stage(call: &ActiveCall) -> impl IntoElement {47
let stage_size = call.stage_size.clone();51
let stage_size = call.stage_size.clone();@@ -350,6 +354,58 @@ fn rows_of(cells: Vec<AnyElement>, columns: usize) -> Vec<Div> {350
}354
}351
}355
}352
356
357
fn pager_button(358
app: &Entity<AppState>,359
id: &'static str,360
glyph: IconName,361
tooltip: &'static str,362
forward: bool,363
enabled: bool,364
) -> AnyElement {365
let app = app.clone();366
let color = if enabled { theme::text() } else { theme::text_faint() };367
div()368
.id(id)369
.size(px(PAGER_BUTTON))370
.flex()371
.items_center()372
.justify_center()373
.rounded_full()374
.child(icon(glyph, PAGER_ICON, color))375
.when(enabled, |button| {376
button377
.cursor_pointer()378
.hover(|button| button.bg(theme::row_hover()))379
.tooltip(move |window, cx| Tooltip::new(tooltip).build(window, cx))380
.on_click(move |_, _, cx| {381
app.update(cx, |state, cx| state.turn_call_gallery_page(forward, cx));382
})383
})384
.into_any_element()385
}386
387
fn gallery_pager(app: &Entity<AppState>, page: usize, pages: usize) -> AnyElement {388
h_flex()389
.debug_selector(|| GALLERY_PAGER_TAG.into())390
.h(px(PAGER_HEIGHT))391
.px(px(2.))392
.gap(px(4.))393
.items_center()394
.rounded_full()395
.bg(theme::row_hover())396
.child(pager_button(app, "call-gallery-previous", IconName::ChevronLeft, "Previous page", false, page > 0))397
.child(398
div()399
.min_w(px(40.))400
.text_center()401
.text_size(px(12.))402
.text_color(theme::text_soft())403
.child(format!("{} / {}", page + 1, pages)),404
)405
.child(pager_button(app, "call-gallery-next", IconName::ChevronRight, "Next page", true, page + 1 < pages))406
.into_any_element()407
}408
353
fn gallery_body(409
fn gallery_body(354
app: &Entity<AppState>,410
app: &Entity<AppState>,355
state: &AppState,411
state: &AppState,@@ -357,30 +413,28 @@ fn gallery_body(357
now: Instant,413
now: Instant,358
stage: (f32, f32),414
stage: (f32, f32),359
) -> AnyElement {415
) -> AnyElement {360
let (others, overflow) = gallery_split(model);416
let page = gallery_page(model);361
let own_cells = model.own_cells();417
let paged = page.pages > 1;362
let cells = overflow.shown + own_cells + usize::from(overflow.hidden > 0);418
let pager_room = if paged { PAGER_HEIGHT + TILE_GAP } else { 0. };419
let cells = page.tiles.len() + usize::from(page.own);363
let grid = gallery_grid(420
let grid = gallery_grid(364
cells,421
cells,365
stage.0 - 2. * GRID_PADDING,422
stage.0 - 2. * GRID_PADDING,366
stage.1 - 2. * GRID_PADDING,423
stage.1 - 2. * GRID_PADDING - pager_room,367
TILE_GAP,424
TILE_GAP,368
);425
);369
let size = TileSize::sixteen_by_nine(grid.tile_width.floor());426
let size = TileSize::sixteen_by_nine(grid.tile_width.floor());370
let shown = &others[..overflow.shown];427
let mut tiles: Vec<AnyElement> = page371
let mut tiles: Vec<AnyElement> = shown428
.tiles372
.iter()429
.iter()373
.map(|tile| person_tile(app, state, model, tile, size, now))430
.map(|tile| person_tile(app, state, model, tile, size, now))374
.collect();431
.collect();375
if own_cells > 0 {432
if page.own {376
tiles.insert(433
tiles.insert(377
own_slot(model, shown),434
own_slot(model, &page.tiles),378
own_tile(app, state, model, size, now),435
own_tile(app, state, model, size, now),379
);436
);380
}437
}381
if overflow.hidden > 0 {382
tiles.push(overflow_tile(app, state, size, &others[overflow.shown..]));383
}384
v_flex()438
v_flex()385
.absolute()439
.absolute()386
.inset_0()440
.inset_0()@@ -388,6 +442,7 @@ fn gallery_body(388
.justify_center()442
.justify_center()389
.gap(px(TILE_GAP))443
.gap(px(TILE_GAP))390
.children(rows_of(tiles, grid.columns))444
.children(rows_of(tiles, grid.columns))445
.when(paged, |body| body.child(gallery_pager(app, page.page, page.pages)))391
.into_any_element()446
.into_any_element()392
}447
}393
448