feat(calls): call toolbar in the order of the current Teams
- Mic, Camera, Share first, then React, Chat, People, then Pop out and More, Leave on the right - Raise hand moved into the React menu, React lights up while the hand is raised - View moved into More - Pop out sits in the toolbar while someone shares instead of on the stage - Deviation: no Copilot and no Take control button, both are not supported Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -37,21 +37,32 @@ impl FoldedControls {
37
37
}
38
38
}
39
39
40
pub fn fixed_controls_width(has_camera_menu: bool, has_more: bool, has_leave_menu: bool) -> f32 {
40
pub fn fixed_controls_width(has_camera_menu: bool, has_more: bool, has_leave_menu: bool, has_pop_out: bool) -> f32 {
41
41
let devices = [
42
42
TOOL_WIDTH + if has_camera_menu { SPLIT_CHEVRON_WIDTH } else { 0. },
43
43
TOOL_WIDTH + SPLIT_CHEVRON_WIDTH,
44
44
TOOL_WIDTH,
45
45
];
46
46
let devices_width = devices.iter().sum::<f32>() + TOOL_GAP * (devices.len() - 1) as f32;
47
let more_width = if has_more { TOOL_WIDTH } else { 0. };
47
let more_width = if has_more { TOOL_WIDTH } else { 0. } + if has_pop_out { TOOL_WIDTH + TOOL_GAP } else { 0. };
48
48
let leave_width = LEAVE_WIDTH
49
49
+ if has_leave_menu {
50
50
SPLIT_CHEVRON_WIDTH + 4. + 1.
51
51
} else {
52
52
0.
53
53
};
54
devices_width + more_width + leave_width + 2. * GROUP_GAP
54
devices_width + more_width + leave_width + 3. * GROUP_GAP
55
}
56
57
pub fn in_more_menu(folded: Vec<Foldable>) -> Vec<Foldable> {
58
let mut items = vec![Foldable::View];
59
for control in folded {
60
items.push(control);
61
if control == Foldable::Reactions {
62
items.push(Foldable::RaiseHand);
63
}
64
}
65
items
55
66
}
56
67
57
68
pub fn folded_for_width(available: f32, fixed: f32, present: &[Foldable]) -> Vec<Foldable> {
@@ -173,15 +184,9 @@ fn chat_item(popup: PopupMenu, app: &Entity<AppState>, folded: &FoldedControls)
173
184
174
185
#[cfg(test)]
175
186
mod tests {
176
use super::{Foldable, TITLE_RESERVE, 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
];
187
use super::{Foldable, TITLE_RESERVE, fixed_controls_width, folded_for_width, in_more_menu};
188
189
const ALL: [Foldable; 3] = [Foldable::Reactions, Foldable::People, Foldable::Chat];
185
190
const SLOT: f32 = 56. + 2.;
186
191
const FIXED: f32 = 400.;
187
192
@@ -191,16 +196,16 @@ mod tests {
191
196
192
197
#[test]
193
198
fn nothing_folds_when_everything_fits() {
194
assert!(folded_for_width(width_for(5.), FIXED, &ALL).is_empty());
199
assert!(folded_for_width(width_for(3.), FIXED, &ALL).is_empty());
195
200
assert!(folded_for_width(width_for(9.), FIXED, &ALL).is_empty());
196
201
}
197
202
198
203
#[test]
199
fn folds_view_first_then_reactions() {
200
assert_eq!(folded_for_width(width_for(4.), FIXED, &ALL), [Foldable::View]);
204
fn folds_reactions_first_then_people() {
205
assert_eq!(folded_for_width(width_for(2.), FIXED, &ALL), [Foldable::Reactions]);
201
206
assert_eq!(
202
folded_for_width(width_for(3.), FIXED, &ALL),
203
[Foldable::View, Foldable::Reactions]
207
folded_for_width(width_for(1.), FIXED, &ALL),
208
[Foldable::Reactions, Foldable::People]
204
209
);
205
210
}
206
211
@@ -211,20 +216,20 @@ mod tests {
211
216
}
212
217
213
218
#[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());
219
fn view_always_sits_in_more_and_the_hand_follows_the_reactions() {
220
assert_eq!(in_more_menu(Vec::new()), [Foldable::View]);
217
221
assert_eq!(
218
folded_for_width(width_for(1.), FIXED, &present),
219
[Foldable::View]
222
in_more_menu(vec![Foldable::Reactions, Foldable::Chat]),
223
[Foldable::View, Foldable::Reactions, Foldable::RaiseHand, Foldable::Chat]
220
224
);
221
225
}
222
226
223
227
#[test]
224
228
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 + 20.);
227
assert_eq!(fixed_controls_width(false, true, false), base + 56.);
228
assert_eq!(fixed_controls_width(false, false, true), base + 25.);
229
let base = fixed_controls_width(false, false, false, false);
230
assert_eq!(fixed_controls_width(true, false, false, false), base + 20.);
231
assert_eq!(fixed_controls_width(false, true, false, false), base + 56.);
232
assert_eq!(fixed_controls_width(false, false, true, false), base + 25.);
233
assert_eq!(fixed_controls_width(false, false, false, true), base + 58.);
229
234
}
230
235
}
@@ -37,21 +37,32 @@ impl FoldedControls {37
}37
}38
}38
}39
39
40
pub fn fixed_controls_width(has_camera_menu: bool, has_more: bool, has_leave_menu: bool) -> f32 {40
pub fn fixed_controls_width(has_camera_menu: bool, has_more: bool, has_leave_menu: bool, has_pop_out: bool) -> f32 {41
let devices = [41
let devices = [42
TOOL_WIDTH + if has_camera_menu { SPLIT_CHEVRON_WIDTH } else { 0. },42
TOOL_WIDTH + if has_camera_menu { SPLIT_CHEVRON_WIDTH } else { 0. },43
TOOL_WIDTH + SPLIT_CHEVRON_WIDTH,43
TOOL_WIDTH + SPLIT_CHEVRON_WIDTH,44
TOOL_WIDTH,44
TOOL_WIDTH,45
];45
];46
let devices_width = devices.iter().sum::<f32>() + TOOL_GAP * (devices.len() - 1) as f32;46
let devices_width = devices.iter().sum::<f32>() + TOOL_GAP * (devices.len() - 1) as f32;47
let more_width = if has_more { TOOL_WIDTH } else { 0. };47
let more_width = if has_more { TOOL_WIDTH } else { 0. } + if has_pop_out { TOOL_WIDTH + TOOL_GAP } else { 0. };48
let leave_width = LEAVE_WIDTH48
let leave_width = LEAVE_WIDTH49
+ if has_leave_menu {49
+ if has_leave_menu {50
SPLIT_CHEVRON_WIDTH + 4. + 1.50
SPLIT_CHEVRON_WIDTH + 4. + 1.51
} else {51
} else {52
0.52
0.53
};53
};54
devices_width + more_width + leave_width + 2. * GROUP_GAP54
devices_width + more_width + leave_width + 3. * GROUP_GAP55
}56
57
pub fn in_more_menu(folded: Vec<Foldable>) -> Vec<Foldable> {58
let mut items = vec![Foldable::View];59
for control in folded {60
items.push(control);61
if control == Foldable::Reactions {62
items.push(Foldable::RaiseHand);63
}64
}65
items55
}66
}56
67
57
pub fn folded_for_width(available: f32, fixed: f32, present: &[Foldable]) -> Vec<Foldable> {68
pub fn folded_for_width(available: f32, fixed: f32, present: &[Foldable]) -> Vec<Foldable> {@@ -173,15 +184,9 @@ fn chat_item(popup: PopupMenu, app: &Entity<AppState>, folded: &FoldedControls)173
184
174
#[cfg(test)]185
#[cfg(test)]175
mod tests {186
mod tests {176
use super::{Foldable, TITLE_RESERVE, fixed_controls_width, folded_for_width};187
use super::{Foldable, TITLE_RESERVE, fixed_controls_width, folded_for_width, in_more_menu};177
188
178
const ALL: [Foldable; 5] = [189
const ALL: [Foldable; 3] = [Foldable::Reactions, Foldable::People, Foldable::Chat];179
Foldable::View,180
Foldable::Reactions,181
Foldable::RaiseHand,182
Foldable::People,183
Foldable::Chat,184
];185
const SLOT: f32 = 56. + 2.;190
const SLOT: f32 = 56. + 2.;186
const FIXED: f32 = 400.;191
const FIXED: f32 = 400.;187
192
@@ -191,16 +196,16 @@ mod tests {191
196
192
#[test]197
#[test]193
fn nothing_folds_when_everything_fits() {198
fn nothing_folds_when_everything_fits() {194
assert!(folded_for_width(width_for(5.), FIXED, &ALL).is_empty());199
assert!(folded_for_width(width_for(3.), FIXED, &ALL).is_empty());195
assert!(folded_for_width(width_for(9.), FIXED, &ALL).is_empty());200
assert!(folded_for_width(width_for(9.), FIXED, &ALL).is_empty());196
}201
}197
202
198
#[test]203
#[test]199
fn folds_view_first_then_reactions() {204
fn folds_reactions_first_then_people() {200
assert_eq!(folded_for_width(width_for(4.), FIXED, &ALL), [Foldable::View]);205
assert_eq!(folded_for_width(width_for(2.), FIXED, &ALL), [Foldable::Reactions]);201
assert_eq!(206
assert_eq!(202
folded_for_width(width_for(3.), FIXED, &ALL),207
folded_for_width(width_for(1.), FIXED, &ALL),203
[Foldable::View, Foldable::Reactions]208
[Foldable::Reactions, Foldable::People]204
);209
);205
}210
}206
211
@@ -211,20 +216,20 @@ mod tests {211
}216
}212
217
213
#[test]218
#[test]214
fn only_present_controls_are_counted() {219
fn view_always_sits_in_more_and_the_hand_follows_the_reactions() {215
let present = [Foldable::View, Foldable::People];220
assert_eq!(in_more_menu(Vec::new()), [Foldable::View]);216
assert!(folded_for_width(width_for(2.), FIXED, &present).is_empty());217
assert_eq!(221
assert_eq!(218
folded_for_width(width_for(1.), FIXED, &present),222
in_more_menu(vec![Foldable::Reactions, Foldable::Chat]),219
[Foldable::View]223
[Foldable::View, Foldable::Reactions, Foldable::RaiseHand, Foldable::Chat]220
);224
);221
}225
}222
226
223
#[test]227
#[test]224
fn fixed_width_counts_optional_controls() {228
fn fixed_width_counts_optional_controls() {225
let base = fixed_controls_width(false, false, false);229
let base = fixed_controls_width(false, false, false, false);226
assert_eq!(fixed_controls_width(true, false, false), base + 20.);230
assert_eq!(fixed_controls_width(true, false, false, false), base + 20.);227
assert_eq!(fixed_controls_width(false, true, false), base + 56.);231
assert_eq!(fixed_controls_width(false, true, false, false), base + 56.);228
assert_eq!(fixed_controls_width(false, false, true), base + 25.);232
assert_eq!(fixed_controls_width(false, false, true, false), base + 25.);233
assert_eq!(fixed_controls_width(false, false, false, true), base + 58.);229
}234
}230
}235
}@@ -141,36 +141,6 @@ fn zoom_chip(app: &Entity<AppState>, stage: &ShareStage) -> Option<AnyElement> {
141
141
)
142
142
}
143
143
144
fn pop_out_button(app: &Entity<AppState>) -> AnyElement {
145
let app = app.clone();
146
div()
147
.absolute()
148
.bottom(px(LABEL_OFFSET))
149
.right(px(LABEL_OFFSET))
150
.child(
151
h_flex()
152
.id("call-stage-pop-out")
153
.h(px(CHIP_HEIGHT))
154
.px(px(12.))
155
.gap(px(8.))
156
.items_center()
157
.rounded_full()
158
.bg(hsla(0., 0., 0., LABEL_BACKGROUND))
159
.text_color(theme::white())
160
.text_size(px(13.))
161
.font_weight(FontWeight::SEMIBOLD)
162
.cursor_pointer()
163
.hover(|chip| chip.opacity(0.85))
164
.child(icon(IconName::ExternalLink, 15., theme::white()))
165
.child(POP_OUT_TOOLTIP)
166
.on_click(move |_, _, cx| {
167
cx.stop_propagation();
168
app.update(cx, |state, cx| state.pop_out_stage(cx));
169
}),
170
)
171
.into_any_element()
172
}
173
174
144
pub fn popped_placeholder(app: &Entity<AppState>) -> AnyElement {
175
145
let app = app.clone();
176
146
v_flex()
@@ -280,7 +250,6 @@ pub fn render_stage(
280
250
.child(picture(image, share_stage))
281
251
.child(label_chip(label))
282
252
.children(zoom_chip(app, share_stage))
283
.when(mode == StageMode::Docked, |stage| stage.child(pop_out_button(app)))
284
253
.when(mode == StageMode::Fullscreen, |stage| {
285
254
stage.child(
286
255
div()
@@ -141,36 +141,6 @@ fn zoom_chip(app: &Entity<AppState>, stage: &ShareStage) -> Option<AnyElement> {141
)141
)142
}142
}143
143
144
fn pop_out_button(app: &Entity<AppState>) -> AnyElement {145
let app = app.clone();146
div()147
.absolute()148
.bottom(px(LABEL_OFFSET))149
.right(px(LABEL_OFFSET))150
.child(151
h_flex()152
.id("call-stage-pop-out")153
.h(px(CHIP_HEIGHT))154
.px(px(12.))155
.gap(px(8.))156
.items_center()157
.rounded_full()158
.bg(hsla(0., 0., 0., LABEL_BACKGROUND))159
.text_color(theme::white())160
.text_size(px(13.))161
.font_weight(FontWeight::SEMIBOLD)162
.cursor_pointer()163
.hover(|chip| chip.opacity(0.85))164
.child(icon(IconName::ExternalLink, 15., theme::white()))165
.child(POP_OUT_TOOLTIP)166
.on_click(move |_, _, cx| {167
cx.stop_propagation();168
app.update(cx, |state, cx| state.pop_out_stage(cx));169
}),170
)171
.into_any_element()172
}173
174
pub fn popped_placeholder(app: &Entity<AppState>) -> AnyElement {144
pub fn popped_placeholder(app: &Entity<AppState>) -> AnyElement {175
let app = app.clone();145
let app = app.clone();176
v_flex()146
v_flex()@@ -280,7 +250,6 @@ pub fn render_stage(280
.child(picture(image, share_stage))250
.child(picture(image, share_stage))281
.child(label_chip(label))251
.child(label_chip(label))282
.children(zoom_chip(app, share_stage))252
.children(zoom_chip(app, share_stage))283
.when(mode == StageMode::Docked, |stage| stage.child(pop_out_button(app)))284
.when(mode == StageMode::Fullscreen, |stage| {253
.when(mode == StageMode::Fullscreen, |stage| {285
stage.child(254
stage.child(286
div()255
div()@@ -16,7 +16,7 @@ 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::{Foldable, FoldedControls, fixed_controls_width, folded_for_width};
19
use super::call_control_fold::{Foldable, FoldedControls, fixed_controls_width, folded_for_width, in_more_menu};
20
20
use super::call_toolbar::{
21
21
GROUP_GAP, LEAVE_HEIGHT, SPLIT_CHEVRON_WIDTH, TOOL_GAP, tool_face, tool_trigger, split_chevron,
22
22
};
@@ -32,7 +32,7 @@ use super::call_organizer::{
32
32
more_button, pin_chip, spotlight_chip, with_tile_menu,
33
33
};
34
34
use super::call_people::{lock_banner, lock_chip, options_dialog, people_button, people_panel};
35
use super::call_stage::{StageMode, popped_placeholder, render_stage};
35
use super::call_stage::{POP_OUT_TOOLTIP, StageMode, popped_placeholder, render_stage};
36
36
use super::call_view_menu::view_button;
37
37
use app_ui_kit::layout::ISLAND_GAP;
38
38
use super::widgets::{Corner, corner_badge, count_badge, icon};
@@ -825,24 +825,9 @@ fn chat_button(app: &Entity<AppState>, open: bool, unread: u32) -> Stateful<Div>
825
825
.on_click(move |_, _, cx| app.update(cx, |state, cx| state.toggle_call_chat(cx)))
826
826
}
827
827
828
fn hand_button(app: &Entity<AppState>, model: &CallModel) -> Stateful<Div> {
829
let raised = model.own_hand.is_some();
830
let label = if raised { "Lower" } else { "Raise" };
831
let button = tool_face("call-hand", IconName::Hand, label, raised);
832
let tooltip = if raised { "Lower hand" } else { "Raise hand" };
833
let button = button.tooltip(move |window, cx| Tooltip::new(tooltip).build(window, cx));
834
if !model.can_react() {
835
return button.opacity(DISABLED_OPACITY).cursor_default();
836
}
837
let app = app.clone();
838
button.on_click(move |_, _, cx| {
839
cx.stop_propagation();
840
app.update(cx, |state, cx| state.toggle_call_hand(cx));
841
})
842
}
843
844
828
fn reactions_button(app: &Entity<AppState>, model: &CallModel) -> AnyElement {
845
let face = tool_face("call-reactions-face", IconName::FaceSlightlySmiling, "React", false);
829
let raised = model.own_hand.is_some();
830
let face = tool_face("call-reactions-face", IconName::FaceSlightlySmiling, "React", raised);
846
831
if !model.can_react() {
847
832
return face
848
833
.opacity(DISABLED_OPACITY)
@@ -856,7 +841,9 @@ fn reactions_button(app: &Entity<AppState>, model: &CallModel) -> AnyElement {
856
841
.trigger(tool_trigger("call-reactions", face))
857
842
.content(move |_, _, cx| {
858
843
let popover = cx.entity().downgrade();
859
h_flex()
844
let hand_app = app.clone();
845
let hand_popover = popover.clone();
846
let reactions = h_flex()
860
847
.id("call-reactions-row")
861
848
.gap(px(4.))
862
849
.children(Reaction::ALL.into_iter().map(|reaction| {
@@ -879,11 +866,44 @@ fn reactions_button(app: &Entity<AppState>, model: &CallModel) -> AnyElement {
879
866
.update(cx, |state, cx| state.dismiss(window, cx))
880
867
.ok();
881
868
})
882
}))
869
}));
870
v_flex()
871
.gap(px(6.))
872
.child(reactions)
873
.child(
874
h_flex()
875
.id("call-hand")
876
.h(px(36.))
877
.px(px(10.))
878
.gap(px(8.))
879
.items_center()
880
.rounded(px(8.))
881
.cursor_pointer()
882
.when(raised, |row| row.bg(theme::accent_soft()))
883
.hover(|row| row.bg(theme::border_strong()))
884
.child(icon(IconName::Hand, 18., if raised { theme::accent_text() } else { theme::text() }))
885
.child(div().text_size(px(13.)).child(if raised { "Lower hand" } else { "Raise hand" }))
886
.on_click(move |_, window, cx| {
887
hand_app.update(cx, |state, cx| state.toggle_call_hand(cx));
888
hand_popover
889
.update(cx, |state, cx| state.dismiss(window, cx))
890
.ok();
891
}),
892
)
883
893
})
884
894
.into_any_element()
885
895
}
886
896
897
fn pop_out_tool(app: &Entity<AppState>) -> Stateful<Div> {
898
let app = app.clone();
899
tool_face("call-pop-out", IconName::ExternalLink, POP_OUT_TOOLTIP, false)
900
.on_click(move |_, _, cx| app.update(cx, |state, cx| state.pop_out_stage(cx)))
901
}
902
903
fn shows_pop_out(call: &ActiveCall) -> bool {
904
call.model.screen_sharer.is_some() && !call.share_stage.popped
905
}
906
887
907
fn leave_group(app: &Entity<AppState>, model: &CallModel) -> AnyElement {
888
908
let leave = leave_button(app, model, "call-leave", false)
889
909
.rounded(px(LEAVE_RADIUS))
@@ -1215,9 +1235,9 @@ fn folded_controls(state: &AppState, call: &ActiveCall, fullscreen: bool) -> Fol
1215
1235
if !has_more {
1216
1236
return FoldedControls::default();
1217
1237
}
1218
let mut present = vec![Foldable::View];
1238
let mut present = Vec::new();
1219
1239
if model.has_reaction_controls() {
1220
present.extend([Foldable::Reactions, Foldable::RaiseHand]);
1240
present.push(Foldable::Reactions);
1221
1241
}
1222
1242
if model.kind != CallKind::Test {
1223
1243
present.push(Foldable::People);
@@ -1229,9 +1249,10 @@ fn folded_controls(state: &AppState, call: &ActiveCall, fullscreen: bool) -> Fol
1229
1249
model.can_use_camera(),
1230
1250
has_more,
1231
1251
has_leave_menu(model),
1252
shows_pop_out(call),
1232
1253
);
1233
1254
FoldedControls {
1234
items: folded_for_width(measured_stage(call).0, fixed, &present),
1255
items: in_more_menu(folded_for_width(measured_stage(call).0, fixed, &present)),
1235
1256
fullscreen,
1236
1257
people_open: call.people_open,
1237
1258
chat_open: call.chat_open,
@@ -1289,6 +1310,10 @@ pub fn render_call_view(
1289
1310
let panels_and_reactions = h_flex()
1290
1311
.gap(px(TOOL_GAP))
1291
1312
.items_center()
1313
.when(
1314
model.has_reaction_controls() && !folded.folds(Foldable::Reactions),
1315
|row| row.child(reactions_button(app, model)),
1316
)
1292
1317
.when(
1293
1318
call.chat_thread().is_some() && !folded.folds(Foldable::Chat),
1294
1319
|row| row.child(chat_button(app, call.chat_open, state.call_chat_unread())),
@@ -1296,15 +1321,11 @@ pub fn render_call_view(
1296
1321
.when(
1297
1322
model.kind != CallKind::Test && !folded.folds(Foldable::People),
1298
1323
|row| row.child(people_button(app, call.people_open, model.raised_hands())),
1299
)
1300
.when(
1301
model.has_reaction_controls() && !folded.folds(Foldable::RaiseHand),
1302
|row| row.child(hand_button(app, model)),
1303
)
1304
.when(
1305
model.has_reaction_controls() && !folded.folds(Foldable::Reactions),
1306
|row| row.child(reactions_button(app, model)),
1307
)
1324
);
1325
let stage_and_more = h_flex()
1326
.gap(px(TOOL_GAP))
1327
.items_center()
1328
.when(shows_pop_out(call), |row| row.child(pop_out_tool(app)))
1308
1329
.when(!folded.folds(Foldable::View), |row| {
1309
1330
row.child(view_button(app, model, fullscreen))
1310
1331
})
@@ -1314,16 +1335,16 @@ pub fn render_call_view(
1314
1335
.items_center()
1315
1336
.child(
1316
1337
h_flex()
1338
.debug_selector(|| "shell/islands/main/call-header/controls/mic".into())
1317
1339
.items_center()
1318
.child(toolbar_camera(app, model))
1319
.children(camera_menu_button(app, model, CameraMenu::of(state))),
1340
.child(toolbar_mic(app, model))
1341
.child(mic_menu_button(app, model, state.call_mic)),
1320
1342
)
1321
1343
.child(
1322
1344
h_flex()
1323
.debug_selector(|| "shell/islands/main/call-header/controls/mic".into())
1324
1345
.items_center()
1325
.child(toolbar_mic(app, model))
1326
.child(mic_menu_button(app, model, state.call_mic)),
1346
.child(toolbar_camera(app, model))
1347
.children(camera_menu_button(app, model, CameraMenu::of(state))),
1327
1348
)
1328
1349
.child(share_button(
1329
1350
app,
@@ -1336,8 +1357,9 @@ pub fn render_call_view(
1336
1357
.flex_none()
1337
1358
.gap(px(GROUP_GAP))
1338
1359
.items_center()
1339
.child(panels_and_reactions)
1340
1360
.child(devices)
1361
.child(panels_and_reactions)
1362
.child(stage_and_more)
1341
1363
.child(leave_group(app, model));
1342
1364
let header = header.child(controls);
1343
1365
@@ -16,7 +16,7 @@ use gpui_kit::prelude::FluentBuilder as _;16
use gpui_kit::*;16
use gpui_kit::*;17
17
18
use super::avatar::person_avatar;18
use super::avatar::person_avatar;19
use super::call_control_fold::{Foldable, FoldedControls, fixed_controls_width, folded_for_width};19
use super::call_control_fold::{Foldable, FoldedControls, fixed_controls_width, folded_for_width, in_more_menu};20
use super::call_toolbar::{20
use super::call_toolbar::{21
GROUP_GAP, LEAVE_HEIGHT, SPLIT_CHEVRON_WIDTH, TOOL_GAP, tool_face, tool_trigger, split_chevron,21
GROUP_GAP, LEAVE_HEIGHT, SPLIT_CHEVRON_WIDTH, TOOL_GAP, tool_face, tool_trigger, split_chevron,22
};22
};@@ -32,7 +32,7 @@ use super::call_organizer::{32
more_button, pin_chip, spotlight_chip, with_tile_menu,32
more_button, pin_chip, spotlight_chip, with_tile_menu,33
};33
};34
use super::call_people::{lock_banner, lock_chip, options_dialog, people_button, people_panel};34
use super::call_people::{lock_banner, lock_chip, options_dialog, people_button, people_panel};35
use super::call_stage::{StageMode, popped_placeholder, render_stage};35
use super::call_stage::{POP_OUT_TOOLTIP, StageMode, popped_placeholder, render_stage};36
use super::call_view_menu::view_button;36
use super::call_view_menu::view_button;37
use app_ui_kit::layout::ISLAND_GAP;37
use app_ui_kit::layout::ISLAND_GAP;38
use super::widgets::{Corner, corner_badge, count_badge, icon};38
use super::widgets::{Corner, corner_badge, count_badge, icon};@@ -825,24 +825,9 @@ fn chat_button(app: &Entity<AppState>, open: bool, unread: u32) -> Stateful<Div>825
.on_click(move |_, _, cx| app.update(cx, |state, cx| state.toggle_call_chat(cx)))825
.on_click(move |_, _, cx| app.update(cx, |state, cx| state.toggle_call_chat(cx)))826
}826
}827
827
828
fn hand_button(app: &Entity<AppState>, model: &CallModel) -> Stateful<Div> {829
let raised = model.own_hand.is_some();830
let label = if raised { "Lower" } else { "Raise" };831
let button = tool_face("call-hand", IconName::Hand, label, raised);832
let tooltip = if raised { "Lower hand" } else { "Raise hand" };833
let button = button.tooltip(move |window, cx| Tooltip::new(tooltip).build(window, cx));834
if !model.can_react() {835
return button.opacity(DISABLED_OPACITY).cursor_default();836
}837
let app = app.clone();838
button.on_click(move |_, _, cx| {839
cx.stop_propagation();840
app.update(cx, |state, cx| state.toggle_call_hand(cx));841
})842
}843
844
fn reactions_button(app: &Entity<AppState>, model: &CallModel) -> AnyElement {828
fn reactions_button(app: &Entity<AppState>, model: &CallModel) -> AnyElement {845
let face = tool_face("call-reactions-face", IconName::FaceSlightlySmiling, "React", false);829
let raised = model.own_hand.is_some();830
let face = tool_face("call-reactions-face", IconName::FaceSlightlySmiling, "React", raised);846
if !model.can_react() {831
if !model.can_react() {847
return face832
return face848
.opacity(DISABLED_OPACITY)833
.opacity(DISABLED_OPACITY)@@ -856,7 +841,9 @@ fn reactions_button(app: &Entity<AppState>, model: &CallModel) -> AnyElement {856
.trigger(tool_trigger("call-reactions", face))841
.trigger(tool_trigger("call-reactions", face))857
.content(move |_, _, cx| {842
.content(move |_, _, cx| {858
let popover = cx.entity().downgrade();843
let popover = cx.entity().downgrade();859
h_flex()844
let hand_app = app.clone();845
let hand_popover = popover.clone();846
let reactions = h_flex()860
.id("call-reactions-row")847
.id("call-reactions-row")861
.gap(px(4.))848
.gap(px(4.))862
.children(Reaction::ALL.into_iter().map(|reaction| {849
.children(Reaction::ALL.into_iter().map(|reaction| {@@ -879,11 +866,44 @@ fn reactions_button(app: &Entity<AppState>, model: &CallModel) -> AnyElement {879
.update(cx, |state, cx| state.dismiss(window, cx))866
.update(cx, |state, cx| state.dismiss(window, cx))880
.ok();867
.ok();881
})868
})882
}))869
}));870
v_flex()871
.gap(px(6.))872
.child(reactions)873
.child(874
h_flex()875
.id("call-hand")876
.h(px(36.))877
.px(px(10.))878
.gap(px(8.))879
.items_center()880
.rounded(px(8.))881
.cursor_pointer()882
.when(raised, |row| row.bg(theme::accent_soft()))883
.hover(|row| row.bg(theme::border_strong()))884
.child(icon(IconName::Hand, 18., if raised { theme::accent_text() } else { theme::text() }))885
.child(div().text_size(px(13.)).child(if raised { "Lower hand" } else { "Raise hand" }))886
.on_click(move |_, window, cx| {887
hand_app.update(cx, |state, cx| state.toggle_call_hand(cx));888
hand_popover889
.update(cx, |state, cx| state.dismiss(window, cx))890
.ok();891
}),892
)883
})893
})884
.into_any_element()894
.into_any_element()885
}895
}886
896
897
fn pop_out_tool(app: &Entity<AppState>) -> Stateful<Div> {898
let app = app.clone();899
tool_face("call-pop-out", IconName::ExternalLink, POP_OUT_TOOLTIP, false)900
.on_click(move |_, _, cx| app.update(cx, |state, cx| state.pop_out_stage(cx)))901
}902
903
fn shows_pop_out(call: &ActiveCall) -> bool {904
call.model.screen_sharer.is_some() && !call.share_stage.popped905
}906
887
fn leave_group(app: &Entity<AppState>, model: &CallModel) -> AnyElement {907
fn leave_group(app: &Entity<AppState>, model: &CallModel) -> AnyElement {888
let leave = leave_button(app, model, "call-leave", false)908
let leave = leave_button(app, model, "call-leave", false)889
.rounded(px(LEAVE_RADIUS))909
.rounded(px(LEAVE_RADIUS))@@ -1215,9 +1235,9 @@ fn folded_controls(state: &AppState, call: &ActiveCall, fullscreen: bool) -> Fol1215
if !has_more {1235
if !has_more {1216
return FoldedControls::default();1236
return FoldedControls::default();1217
}1237
}1218
let mut present = vec![Foldable::View];1238
let mut present = Vec::new();1219
if model.has_reaction_controls() {1239
if model.has_reaction_controls() {1220
present.extend([Foldable::Reactions, Foldable::RaiseHand]);1240
present.push(Foldable::Reactions);1221
}1241
}1222
if model.kind != CallKind::Test {1242
if model.kind != CallKind::Test {1223
present.push(Foldable::People);1243
present.push(Foldable::People);@@ -1229,9 +1249,10 @@ fn folded_controls(state: &AppState, call: &ActiveCall, fullscreen: bool) -> Fol1229
model.can_use_camera(),1249
model.can_use_camera(),1230
has_more,1250
has_more,1231
has_leave_menu(model),1251
has_leave_menu(model),1252
shows_pop_out(call),1232
);1253
);1233
FoldedControls {1254
FoldedControls {1234
items: folded_for_width(measured_stage(call).0, fixed, &present),1255
items: in_more_menu(folded_for_width(measured_stage(call).0, fixed, &present)),1235
fullscreen,1256
fullscreen,1236
people_open: call.people_open,1257
people_open: call.people_open,1237
chat_open: call.chat_open,1258
chat_open: call.chat_open,@@ -1289,6 +1310,10 @@ pub fn render_call_view(1289
let panels_and_reactions = h_flex()1310
let panels_and_reactions = h_flex()1290
.gap(px(TOOL_GAP))1311
.gap(px(TOOL_GAP))1291
.items_center()1312
.items_center()1313
.when(1314
model.has_reaction_controls() && !folded.folds(Foldable::Reactions),1315
|row| row.child(reactions_button(app, model)),1316
)1292
.when(1317
.when(1293
call.chat_thread().is_some() && !folded.folds(Foldable::Chat),1318
call.chat_thread().is_some() && !folded.folds(Foldable::Chat),1294
|row| row.child(chat_button(app, call.chat_open, state.call_chat_unread())),1319
|row| row.child(chat_button(app, call.chat_open, state.call_chat_unread())),@@ -1296,15 +1321,11 @@ pub fn render_call_view(1296
.when(1321
.when(1297
model.kind != CallKind::Test && !folded.folds(Foldable::People),1322
model.kind != CallKind::Test && !folded.folds(Foldable::People),1298
|row| row.child(people_button(app, call.people_open, model.raised_hands())),1323
|row| row.child(people_button(app, call.people_open, model.raised_hands())),1299
)1324
);1300
.when(1325
let stage_and_more = h_flex()1301
model.has_reaction_controls() && !folded.folds(Foldable::RaiseHand),1326
.gap(px(TOOL_GAP))1302
|row| row.child(hand_button(app, model)),1327
.items_center()1303
)1328
.when(shows_pop_out(call), |row| row.child(pop_out_tool(app)))1304
.when(1305
model.has_reaction_controls() && !folded.folds(Foldable::Reactions),1306
|row| row.child(reactions_button(app, model)),1307
)1308
.when(!folded.folds(Foldable::View), |row| {1329
.when(!folded.folds(Foldable::View), |row| {1309
row.child(view_button(app, model, fullscreen))1330
row.child(view_button(app, model, fullscreen))1310
})1331
})@@ -1314,16 +1335,16 @@ pub fn render_call_view(1314
.items_center()1335
.items_center()1315
.child(1336
.child(1316
h_flex()1337
h_flex()1338
.debug_selector(|| "shell/islands/main/call-header/controls/mic".into())1317
.items_center()1339
.items_center()1318
.child(toolbar_camera(app, model))1340
.child(toolbar_mic(app, model))1319
.children(camera_menu_button(app, model, CameraMenu::of(state))),1341
.child(mic_menu_button(app, model, state.call_mic)),1320
)1342
)1321
.child(1343
.child(1322
h_flex()1344
h_flex()1323
.debug_selector(|| "shell/islands/main/call-header/controls/mic".into())1324
.items_center()1345
.items_center()1325
.child(toolbar_mic(app, model))1346
.child(toolbar_camera(app, model))1326
.child(mic_menu_button(app, model, state.call_mic)),1347
.children(camera_menu_button(app, model, CameraMenu::of(state))),1327
)1348
)1328
.child(share_button(1349
.child(share_button(1329
app,1350
app,@@ -1336,8 +1357,9 @@ pub fn render_call_view(1336
.flex_none()1357
.flex_none()1337
.gap(px(GROUP_GAP))1358
.gap(px(GROUP_GAP))1338
.items_center()1359
.items_center()1339
.child(panels_and_reactions)1340
.child(devices)1360
.child(devices)1361
.child(panels_and_reactions)1362
.child(stage_and_more)1341
.child(leave_group(app, model));1363
.child(leave_group(app, model));1342
let header = header.child(controls);1364
let header = header.child(controls);1343
1365