BlueGit

ict rusty-teams

Files

rusty-teams / crates / app / src / views / call_view.rs

call_view.rs

call_view.rs 46.4 KiB Download Raw
1use std::sync::Arc;
2use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
3
4use calling::{DeviceEntry, MicSettings, NoiseSuppression, Reaction, VideoKey};
5use gpui_kit::assets::IconName;
6use gpui_kit::component::{
7 button::{Button, ButtonVariants as _},
8 h_flex,
9 menu::{DropdownMenu as _, PopupMenu, PopupMenuItem},
10 popover::Popover,
11 switch::Switch,
12 tooltip::Tooltip,
13 v_flex,
14};
15use gpui_kit::prelude::FluentBuilder as _;
16use gpui_kit::*;
17
18use super::avatar::person_avatar;
19use super::call_control_fold::{
20 CONTROL_GAP, CONTROLS_PADDING, Foldable, FoldedControls, fixed_controls_width, folded_for_width,
21};
22use super::call_extras::{
23 CameraMenu, consent_overlay, consult_banner, hold_panel, recording_chip, return_button,
24 room_chip, whiteboard_stage,
25};
26use super::call_health::{health_banner, health_indicator};
27use super::call_layouts::stage_region;
28use crate::call::measured_stage;
29use super::call_organizer::{
30 camera_menu_button, captions_hint_chip, captions_overlay, chevron_button, lobby_banner,
31 more_button, pin_chip, spotlight_chip, with_tile_menu,
32};
33use super::call_people::{lock_banner, lock_chip, options_dialog, people_button, people_panel};
34use super::call_stage::{StageMode, popped_placeholder, render_stage};
35use super::call_view_menu::view_button;
36use app_ui_kit::layout::ISLAND_GAP;
37use super::widgets::{Corner, corner_badge, count_badge, icon};
38use crate::app_state::AppState;
39use crate::call::REACTION_SHOWN;
40use crate::call::TileSize;
41use crate::call::{ActiveCall, CallKind, CallModel, Tile, TileState};
42use crate::rows::reaction_glyph as chat_reaction_glyph;
43use crate::theme;
44
45const HEADER_HEIGHT: f32 = 60.;
46const RING_WIDTH: f32 = 3.;
47const RING_GAP: f32 = 4.;
48pub(super) const CONTROL_SIZE: f32 = 44.;
49const CONTROL_ICON: f32 = 20.;
50pub(super) const MENU_WIDTH: f32 = 280.;
51const SHARE_MENU_WIDTH: f32 = 360.;
52const PULSE_PERIOD: Duration = Duration::from_millis(1400);
53const BLINK_HALF_PERIOD: Duration = Duration::from_millis(500);
54const BLINK_DIMMED_OPACITY: f32 = 0.45;
55pub(super) const DISABLED_OPACITY: f32 = 0.4;
56const TILE_RADIUS: f32 = 12.;
57const NAME_PLATE_BACKGROUND: f32 = 0.6;
58pub const CHAT_PANEL_TAG: &str = "shell/islands/main/call-chat-panel";
59pub const NO_MICROPHONE_HINT: &str = "No microphone found";
60const AUDIO_OFF_HINT: &str = "Audio is off for this meeting";
61pub const NO_CAMERA_HINT: &str = "No camera found";
62pub const NO_SHARE_HINT: &str = "Sharing starts once the call is connected";
63pub const NO_WINDOWS_HINT: &str = "No windows found";
64pub(super) const BANNER_HEIGHT: f32 = 40.;
65const MAX_WINDOW_ITEMS: usize = 12;
66pub const SHARE_THUMBNAIL_TAG: &str = "call/share-menu/thumbnail";
67const SCREEN_THUMBNAIL: (f32, f32) = (128., 72.);
68const WINDOW_THUMBNAIL: (f32, f32) = (96., 54.);
69const THUMBNAIL_RADIUS: f32 = 6.;
70const THUMBNAIL_ICON: f32 = 22.;
71pub const LOBBY_TEXT: &str = "Waiting in the lobby...";
72pub(super) const CHAT_PANEL_WIDTH: f32 = 320.;
73pub(super) const OVERLAY_BELOW: f32 = 720.;
74const CONTROLS_HEIGHT: f32 = 2. * 16. + CONTROL_SIZE;
75const CHAT_HEADER_HEIGHT: f32 = 48.;
76const REACTION_RISE: f32 = 24.;
77const REACTION_FADE_FROM: f32 = 0.75;
78const REACTION_CELL: f32 = 40.;
79const SHARE_SOUND_LABEL: &str = "Include computer sound";
80const SHARE_MOTION_LABEL: &str = "Optimize for motion";
81const SHARE_STANDOUT_LABEL: &str = "Show me over my content";
82const SHARE_STANDOUT_NEEDS_CAMERA: &str = "Turn your camera on first";
83const NOISE_SUPPRESSION_LABEL: &str = "Noise suppression";
84const MUSIC_MODE_LABEL: &str = "Music mode";
85const PUSH_TO_TALK_HINT: &str = "Unmuted - release Ctrl+Space to mute";
86const PUSH_TO_TALK_TOP: f32 = 12.;
87
88pub fn reaction_glyph(reaction: &Reaction) -> String {
89 match reaction {
90 Reaction::Applause => "\u{1F44F}".to_owned(),
91 other => chat_reaction_glyph(other.name()),
92 }
93}
94
95fn is_emoji_glyph(glyph: &str) -> bool {
96 !glyph.is_ascii()
97}
98
99#[derive(Default)]
100struct TileExtras {
101 hand: Option<usize>,
102 own: bool,
103 reaction: Option<(Reaction, u64)>,
104 spotlight: bool,
105 pinned: bool,
106 fitted: bool,
107}
108
109fn hand_badge(position: usize, own: bool) -> Div {
110 h_flex()
111 .h(px(24.))
112 .px(px(8.))
113 .gap(px(4.))
114 .items_center()
115 .rounded_full()
116 .bg(theme::amber())
117 .text_color(hsla(0., 0., 0.08, 1.))
118 .text_size(px(12.))
119 .font_weight(FontWeight::SEMIBOLD)
120 .child(if own {
121 "Hand raised".to_owned()
122 } else {
123 format!("Hand {position}")
124 })
125}
126
127fn reaction_chip(reaction: Reaction, serial: u64) -> AnyElement {
128 let glyph = reaction_glyph(&reaction);
129 let emoji = is_emoji_glyph(&glyph);
130 div()
131 .absolute()
132 .right(px(12.))
133 .bottom(px(32.))
134 .h(px(36.))
135 .min_w(px(36.))
136 .when(!emoji, |chip| chip.px(px(12.)))
137 .flex()
138 .items_center()
139 .justify_center()
140 .rounded_full()
141 .bg(theme::popup())
142 .text_size(px(if emoji { 20. } else { 13. }))
143 .child(glyph)
144 .with_animation(
145 ("call-reaction", serial as usize),
146 Animation::new(REACTION_SHOWN),
147 |chip, delta| {
148 let fade = ((delta - REACTION_FADE_FROM) / (1. - REACTION_FADE_FROM)).clamp(0., 1.);
149 chip.bottom(px(32. + REACTION_RISE * delta))
150 .opacity(1. - fade)
151 },
152 )
153 .into_any_element()
154}
155
156fn tile_overlays(extras: &TileExtras) -> Vec<AnyElement> {
157 let badges = (extras.hand.is_some() || extras.spotlight || extras.pinned).then(|| {
158 h_flex()
159 .absolute()
160 .top(px(8.))
161 .left(px(8.))
162 .gap(px(6.))
163 .children(extras.hand.map(|position| hand_badge(position, extras.own)))
164 .when(extras.spotlight, |row| row.child(spotlight_chip()))
165 .when(extras.pinned, |row| row.child(pin_chip()))
166 .into_any_element()
167 });
168 let reaction = extras
169 .reaction
170 .clone()
171 .map(|(reaction, serial)| reaction_chip(reaction, serial));
172 badges.into_iter().chain(reaction).collect()
173}
174
175pub fn status_line(model: &CallModel, now: Instant) -> (String, Hsla) {
176 if model.lobby {
177 (LOBBY_TEXT.to_owned(), theme::amber())
178 } else if model.is_connecting() {
179 (model.connecting_text().to_owned(), theme::text_muted())
180 } else if model.is_reconnecting() {
181 ("Reconnecting...".to_owned(), theme::amber())
182 } else if model.view.hide_timer {
183 (String::new(), theme::text_muted())
184 } else {
185 (model.timer_text(now), theme::text_muted())
186 }
187}
188
189pub fn pulsing(element: impl IntoElement + 'static, id: &'static str) -> AnyElement {
190 div()
191 .child(element)
192 .with_animation(
193 id,
194 Animation::new(PULSE_PERIOD).repeat(),
195 |element, delta| {
196 let wave = 1. - (delta * 2. - 1.).abs();
197 element.opacity(0.45 + 0.55 * wave)
198 },
199 )
200 .into_any_element()
201}
202
203fn blinking(element: impl IntoElement + 'static) -> AnyElement {
204 let dimmed = SystemTime::now()
205 .duration_since(UNIX_EPOCH)
206 .is_ok_and(|elapsed| (elapsed.as_millis() / BLINK_HALF_PERIOD.as_millis()) % 2 == 1);
207 div()
208 .child(element)
209 .opacity(if dimmed { BLINK_DIMMED_OPACITY } else { 1. })
210 .into_any_element()
211}
212
213fn speaking_ring(avatar: AnyElement, speaking: bool) -> Div {
214 div()
215 .p(px(RING_GAP))
216 .rounded_full()
217 .border(px(RING_WIDTH))
218 .border_color(if speaking {
219 theme::green()
220 } else {
221 transparent_black()
222 })
223 .child(avatar)
224}
225
226fn mute_badge() -> Div {
227 div()
228 .absolute()
229 .top(px(8.))
230 .right(px(8.))
231 .size(px(24.))
232 .flex()
233 .items_center()
234 .justify_center()
235 .rounded_full()
236 .bg(theme::red())
237 .child(icon(IconName::MicOff, 13., theme::white()))
238}
239
240fn video_tile(
241 size: TileSize,
242 image: Arc<RenderImage>,
243 name: &str,
244 speaking: bool,
245 muted: bool,
246 extras: &TileExtras,
247) -> Div {
248 div()
249 .relative()
250 .w(px(size.width))
251 .h(px(size.height))
252 .flex_none()
253 .overflow_hidden()
254 .rounded(px(TILE_RADIUS))
255 .bg(theme::row_hover())
256 .border_2()
257 .border_color(if speaking {
258 theme::green()
259 } else {
260 transparent_black()
261 })
262 .child(
263 img(ImageSource::Render(image))
264 .size_full()
265 .object_fit(if extras.fitted {
266 ObjectFit::Contain
267 } else {
268 ObjectFit::Cover
269 })
270 .rounded(px(TILE_RADIUS)),
271 )
272 .child(
273 div()
274 .absolute()
275 .left(px(8.))
276 .bottom(px(8.))
277 .max_w(px(size.width - 24.))
278 .truncate()
279 .px(px(8.))
280 .py(px(4.))
281 .rounded(px(6.))
282 .bg(hsla(0., 0., 0., NAME_PLATE_BACKGROUND))
283 .text_size(px(12.))
284 .font_weight(FontWeight::SEMIBOLD)
285 .text_color(theme::white())
286 .child(name.to_owned()),
287 )
288 .when(muted, |tile| tile.child(mute_badge()))
289 .children(tile_overlays(extras))
290}
291
292fn tile(
293 size: TileSize,
294 avatar: AnyElement,
295 name: &str,
296 speaking: bool,
297 muted: bool,
298 caption: Option<AnyElement>,
299 extras: &TileExtras,
300) -> Div {
301 let badge = mute_badge();
302 v_flex()
303 .relative()
304 .w(px(size.width))
305 .h(px(size.height))
306 .items_center()
307 .justify_center()
308 .gap(px(12.))
309 .rounded(px(12.))
310 .bg(theme::row_hover())
311 .child(speaking_ring(avatar, speaking))
312 .child(
313 v_flex()
314 .items_center()
315 .gap(px(2.))
316 .max_w(px(size.width - 16.))
317 .child(
318 div()
319 .max_w_full()
320 .truncate()
321 .text_size(px(14.))
322 .font_weight(FontWeight::SEMIBOLD)
323 .child(name.to_owned()),
324 )
325 .children(caption),
326 )
327 .when(muted, |tile| tile.child(badge))
328 .children(tile_overlays(extras))
329}
330
331fn control_shell(id: &'static str, background: Hsla) -> Stateful<Div> {
332 div()
333 .id(id)
334 .size(px(CONTROL_SIZE))
335 .flex()
336 .flex_none()
337 .items_center()
338 .justify_center()
339 .rounded_full()
340 .bg(background)
341 .cursor_pointer()
342 .hover(|button| button.opacity(0.85))
343}
344
345pub(super) fn round_control(
346 id: &'static str,
347 glyph: IconName,
348 background: Hsla,
349 foreground: Hsla,
350) -> Stateful<Div> {
351 control_shell(id, background).child(icon(glyph, CONTROL_ICON, foreground))
352}
353
354pub fn mute_button(
355 app: &Entity<AppState>,
356 model: &CallModel,
357 id: &'static str,
358 size: f32,
359) -> Stateful<Div> {
360 let (glyph, background, foreground) = if model.muted {
361 (IconName::MicOff, theme::red(), theme::white())
362 } else {
363 (IconName::Mic, theme::surface_raised(), theme::text())
364 };
365 let button = round_control(id, glyph, background, foreground).size(px(size));
366 if !model.can_unmute() {
367 let hint = if model.audio_off {
368 AUDIO_OFF_HINT
369 } else {
370 NO_MICROPHONE_HINT
371 };
372 return button
373 .opacity(DISABLED_OPACITY)
374 .cursor_default()
375 .tooltip(move |window, cx| Tooltip::new(hint).build(window, cx));
376 }
377 let app = app.clone();
378 button.on_click(move |_, _, cx| {
379 cx.stop_propagation();
380 app.update(cx, |state, cx| state.toggle_call_mute(cx));
381 })
382}
383
384pub fn leave_button(
385 app: &Entity<AppState>,
386 model: &CallModel,
387 id: &'static str,
388 compact: bool,
389) -> Stateful<Div> {
390 let label = if model.is_connecting() {
391 "Cancel"
392 } else {
393 "Leave"
394 };
395 let app = app.clone();
396 h_flex()
397 .id(id)
398 .h(px(if compact { 28. } else { CONTROL_SIZE }))
399 .px(px(if compact { 10. } else { 20. }))
400 .gap(px(8.))
401 .flex_none()
402 .items_center()
403 .justify_center()
404 .rounded_full()
405 .bg(theme::red())
406 .text_color(theme::white())
407 .text_size(px(if compact { 12. } else { 14. }))
408 .font_weight(FontWeight::SEMIBOLD)
409 .cursor_pointer()
410 .hover(|button| button.opacity(0.85))
411 .child(icon(
412 IconName::PhoneOff,
413 if compact { 14. } else { 18. },
414 theme::white(),
415 ))
416 .child(label)
417 .on_click(move |_, _, cx| {
418 cx.stop_propagation();
419 app.update(cx, |state, cx| state.leave_call(cx));
420 })
421}
422
423fn share_stage_element(app: &Entity<AppState>, state: &AppState, call: &ActiveCall) -> Option<AnyElement> {
424 if call.share_stage.popped && call.model.screen_sharer.is_some() {
425 return Some(popped_placeholder(app));
426 }
427 render_stage(app, state, StageMode::Docked).or_else(|| whiteboard_stage(app, &call.model))
428}
429
430pub(super) fn camera_button(app: &Entity<AppState>, model: &CallModel) -> Stateful<Div> {
431 let (glyph, background, foreground) = if model.camera_on {
432 (IconName::Video, theme::accent(), theme::on_accent())
433 } else {
434 (IconName::VideoOff, theme::surface_raised(), theme::text())
435 };
436 let button = round_control("call-camera", glyph, background, foreground);
437 if !model.can_use_camera() {
438 return button
439 .opacity(DISABLED_OPACITY)
440 .cursor_default()
441 .tooltip(|window, cx| Tooltip::new(NO_CAMERA_HINT).build(window, cx));
442 }
443 let app = app.clone();
444 button.on_click(move |_, _, cx| {
445 cx.stop_propagation();
446 app.update(cx, |state, cx| state.toggle_call_camera(cx));
447 })
448}
449
450fn sound_switch_item(app: &Entity<AppState>, sound: bool) -> PopupMenuItem {
451 let app = app.clone();
452 PopupMenuItem::element(move |_, _| {
453 h_flex()
454 .id("call-share-sound-row")
455 .w_full()
456 .gap(px(16.))
457 .items_center()
458 .justify_between()
459 .child(SHARE_SOUND_LABEL)
460 .child(Switch::new("call-share-sound").checked(sound))
461 })
462 .on_click(move |_, _, cx| app.update(cx, |state, cx| state.set_call_share_sound(!sound, cx)))
463}
464
465fn motion_switch_item(app: &Entity<AppState>, motion: bool) -> PopupMenuItem {
466 let app = app.clone();
467 PopupMenuItem::element(move |_, _| {
468 h_flex()
469 .id("call-share-motion-row")
470 .w_full()
471 .gap(px(16.))
472 .items_center()
473 .justify_between()
474 .child(SHARE_MOTION_LABEL)
475 .child(Switch::new("call-share-motion").checked(motion))
476 })
477 .on_click(move |_, _, cx| app.update(cx, |state, cx| state.set_call_share_motion(!motion, cx)))
478}
479
480fn standout_switch_item(app: &Entity<AppState>, standout: bool, camera_on: bool) -> PopupMenuItem {
481 let app = app.clone();
482 PopupMenuItem::element(move |_, _| {
483 v_flex()
484 .id("call-share-standout-row")
485 .w_full()
486 .when(!camera_on, |row| row.opacity(DISABLED_OPACITY))
487 .child(
488 h_flex()
489 .w_full()
490 .gap(px(16.))
491 .items_center()
492 .justify_between()
493 .child(SHARE_STANDOUT_LABEL)
494 .child(Switch::new("call-share-standout").checked(standout && camera_on)),
495 )
496 .when(!camera_on, |row| {
497 row.child(
498 div()
499 .text_size(px(11.))
500 .text_color(theme::text_muted())
501 .child(SHARE_STANDOUT_NEEDS_CAMERA),
502 )
503 })
504 })
505 .disabled(!camera_on)
506 .on_click(move |_, _, cx| app.update(cx, |state, cx| state.set_call_share_standout(!standout, cx)))
507}
508
509fn music_mode_item(app: &Entity<AppState>, mic: MicSettings) -> PopupMenuItem {
510 let app = app.clone();
511 PopupMenuItem::element(move |_, _| {
512 h_flex()
513 .id("call-music-mode-row")
514 .w_full()
515 .gap(px(16.))
516 .items_center()
517 .justify_between()
518 .child(MUSIC_MODE_LABEL)
519 .child(Switch::new("call-music-mode").checked(mic.music_mode))
520 })
521 .on_click(move |_, _, cx| {
522 app.update(cx, |state, cx| {
523 let settings = MicSettings {
524 music_mode: !mic.music_mode,
525 ..state.call_mic
526 };
527 state.set_call_mic(settings, cx)
528 })
529 })
530}
531
532fn push_to_talk_chip(call: &ActiveCall) -> Option<AnyElement> {
533 call.push_to_talk.is_held().then(|| {
534 div()
535 .id("call-push-to-talk")
536 .absolute()
537 .top(px(HEADER_HEIGHT + PUSH_TO_TALK_TOP))
538 .left_0()
539 .right_0()
540 .flex()
541 .justify_center()
542 .child(
543 div()
544 .debug_selector(|| "call/push-to-talk".into())
545 .px(px(12.))
546 .py(px(6.))
547 .rounded_full()
548 .bg(hsla(0., 0., 0., NAME_PLATE_BACKGROUND))
549 .text_color(theme::white())
550 .text_size(px(13.))
551 .child(PUSH_TO_TALK_HINT),
552 )
553 .into_any_element()
554 })
555}
556
557#[derive(Debug, Clone, Copy)]
558pub(super) struct ShareOptions {
559 pub sound: bool,
560 pub motion: bool,
561 pub standout: bool,
562}
563
564impl ShareOptions {
565 pub(super) fn of(state: &AppState) -> Self {
566 ShareOptions {
567 sound: state.call_share_sound,
568 motion: state.call_share_motion,
569 standout: state.call_share_standout,
570 }
571 }
572}
573
574fn share_items(
575 popup: PopupMenu,
576 app: &Entity<AppState>,
577 model: &CallModel,
578 options: ShareOptions,
579) -> PopupMenu {
580 let screens = model.screens();
581 let single_screen = screens.len() == 1;
582 let mut popup = popup
583 .min_w(px(SHARE_MENU_WIDTH))
584 .item(sound_switch_item(app, options.sound))
585 .item(motion_switch_item(app, options.motion))
586 .item(standout_switch_item(app, options.standout, model.camera_on))
587 .separator();
588 for (index, source) in screens.into_iter().enumerate() {
589 let label = if single_screen {
590 "Share entire screen".to_owned()
591 } else {
592 format!("Share screen {}", index + 1)
593 };
594 let thumbnail = model.share_thumbnail(source);
595 let source = source.clone();
596 let app = app.clone();
597 popup = popup.item(
598 share_source_item(label, thumbnail, IconName::Monitor, SCREEN_THUMBNAIL).on_click(
599 move |_, _, cx| app.update(cx, |state, cx| state.start_call_share(source.clone(), cx)),
600 ),
601 );
602 }
603 popup = popup
604 .separator()
605 .item(PopupMenuItem::label("Share a window..."));
606 let windows = model.windows();
607 if windows.is_empty() {
608 return popup.item(PopupMenuItem::new(NO_WINDOWS_HINT).disabled(true));
609 }
610 for source in windows.into_iter().take(MAX_WINDOW_ITEMS) {
611 let label = source.label();
612 let thumbnail = model.share_thumbnail(source);
613 let source = source.clone();
614 let app = app.clone();
615 popup = popup.item(
616 share_source_item(label, thumbnail, IconName::AppWindow, WINDOW_THUMBNAIL).on_click(
617 move |_, _, cx| app.update(cx, |state, cx| state.start_call_share(source.clone(), cx)),
618 ),
619 );
620 }
621 popup
622}
623
624fn share_source_item(
625 label: String,
626 thumbnail: Option<Arc<RenderImage>>,
627 fallback: IconName,
628 (width, height): (f32, f32),
629) -> PopupMenuItem {
630 PopupMenuItem::element(move |_, _| {
631 let preview = div()
632 .debug_selector(|| SHARE_THUMBNAIL_TAG.into())
633 .flex_none()
634 .w(px(width))
635 .h(px(height))
636 .rounded(px(THUMBNAIL_RADIUS))
637 .bg(theme::popup_hover())
638 .flex()
639 .items_center()
640 .justify_center();
641 let preview = match &thumbnail {
642 Some(image) => preview.child(
643 img(ImageSource::Render(image.clone()))
644 .size_full()
645 .object_fit(ObjectFit::Contain)
646 .rounded(px(THUMBNAIL_RADIUS)),
647 ),
648 None => preview.child(
649 gpui_kit::component::Icon::new(fallback.clone())
650 .size(px(THUMBNAIL_ICON))
651 .text_color(theme::text_muted()),
652 ),
653 };
654 h_flex()
655 .w_full()
656 .py(px(4.))
657 .gap(px(12.))
658 .items_center()
659 .child(preview)
660 .child(div().flex_1().min_w_0().truncate().child(label.clone()))
661 })
662}
663
664fn share_button(
665 app: &Entity<AppState>,
666 model: &CallModel,
667 options: ShareOptions,
668 menu_open: bool,
669) -> AnyElement {
670 if model.local_share.is_some() {
671 let app = app.clone();
672 return round_control(
673 "call-share-stop",
674 IconName::ScreenShareOff,
675 theme::accent(),
676 theme::on_accent(),
677 )
678 .tooltip(|window, cx| Tooltip::new("Stop sharing").build(window, cx))
679 .on_click(move |_, _, cx| {
680 cx.stop_propagation();
681 app.update(cx, |state, cx| state.stop_call_share(cx));
682 })
683 .into_any_element();
684 }
685 let face = round_control(
686 "call-share-face",
687 IconName::ScreenShare,
688 theme::surface_raised(),
689 theme::text(),
690 );
691 if !model.can_share() {
692 return face
693 .opacity(DISABLED_OPACITY)
694 .cursor_default()
695 .tooltip(|window, cx| Tooltip::new(NO_SHARE_HINT).build(window, cx))
696 .into_any_element();
697 }
698 let app = app.clone();
699 let open_app = app.clone();
700 let model = model.clone();
701 Button::new("call-share")
702 .ghost()
703 .p_0()
704 .size(px(CONTROL_SIZE))
705 .rounded_full()
706 .child(face)
707 .dropdown_menu_with_anchor(Anchor::BottomLeft, move |popup, _, _| {
708 share_items(popup, &app, &model, options)
709 })
710 .open(menu_open)
711 .on_open_change(move |open, _, cx| {
712 open_app.update(cx, |state, cx| state.set_call_share_menu(*open, cx))
713 })
714 .into_any_element()
715}
716
717fn sharing_banner(app: &Entity<AppState>, model: &CallModel, sound: bool) -> Option<AnyElement> {
718 let label = model.local_share.as_ref()?;
719 let sound_app = app.clone();
720 let app = app.clone();
721 Some(
722 h_flex()
723 .id("call-sharing-banner")
724 .w_full()
725 .h(px(BANNER_HEIGHT))
726 .flex_none()
727 .px(px(20.))
728 .gap(px(12.))
729 .items_center()
730 .justify_center()
731 .bg(theme::accent())
732 .text_color(theme::on_accent())
733 .text_size(px(13.))
734 .font_weight(FontWeight::SEMIBOLD)
735 .child(icon(IconName::ScreenShare, 16., theme::on_accent()))
736 .child(format!("You are sharing: {label}"))
737 .child(
738 div()
739 .id("call-sharing-sound")
740 .h(px(26.))
741 .px(px(12.))
742 .flex()
743 .items_center()
744 .rounded_full()
745 .bg(theme::on_accent().opacity(0.2))
746 .cursor_pointer()
747 .hover(|button| button.opacity(0.9))
748 .child(if sound {
749 "Computer sound on"
750 } else {
751 "Computer sound off"
752 })
753 .on_click(move |_, _, cx| {
754 sound_app.update(cx, |state, cx| state.set_call_share_sound(!sound, cx))
755 }),
756 )
757 .child(
758 div()
759 .id("call-sharing-stop")
760 .h(px(26.))
761 .px(px(12.))
762 .flex()
763 .items_center()
764 .rounded_full()
765 .bg(theme::on_accent())
766 .text_color(theme::accent())
767 .cursor_pointer()
768 .hover(|button| button.opacity(0.9))
769 .child("Stop sharing")
770 .on_click(move |_, _, cx| {
771 app.update(cx, |state, cx| state.stop_call_share(cx))
772 }),
773 )
774 .into_any_element(),
775 )
776}
777
778fn chat_button(app: &Entity<AppState>, open: bool, unread: u32) -> Stateful<Div> {
779 let app = app.clone();
780 let (background, foreground) = if open {
781 (theme::accent(), theme::on_accent())
782 } else {
783 (theme::surface_raised(), theme::text())
784 };
785 round_control("call-chat", IconName::MessageCircle, background, foreground)
786 .relative()
787 .tooltip(move |window, cx| {
788 Tooltip::new(if open {
789 "Close the chat"
790 } else {
791 "Open the chat"
792 })
793 .build(window, cx)
794 })
795 .when(unread > 0, |button| {
796 button.child(corner_badge(Corner::TopRight, 4.).child(count_badge(unread, false)))
797 })
798 .on_click(move |_, _, cx| app.update(cx, |state, cx| state.toggle_call_chat(cx)))
799}
800
801fn hand_button(app: &Entity<AppState>, model: &CallModel) -> Stateful<Div> {
802 let raised = model.own_hand.is_some();
803 let background = if raised {
804 theme::accent()
805 } else {
806 theme::surface_raised()
807 };
808 let foreground = if raised {
809 theme::on_accent()
810 } else {
811 theme::text()
812 };
813 let button = control_shell("call-hand", background).child(icon(
814 IconName::Hand,
815 CONTROL_ICON,
816 foreground,
817 ));
818 let tooltip = if raised { "Lower hand" } else { "Raise hand" };
819 let button = button.tooltip(move |window, cx| Tooltip::new(tooltip).build(window, cx));
820 if !model.can_react() {
821 return button.opacity(DISABLED_OPACITY).cursor_default();
822 }
823 let app = app.clone();
824 button.on_click(move |_, _, cx| {
825 cx.stop_propagation();
826 app.update(cx, |state, cx| state.toggle_call_hand(cx));
827 })
828}
829
830fn reactions_button(app: &Entity<AppState>, model: &CallModel) -> AnyElement {
831 let face = control_shell("call-reactions-face", theme::surface_raised()).child(icon(
832 IconName::FaceSlightlySmiling,
833 CONTROL_ICON,
834 theme::text(),
835 ));
836 if !model.can_react() {
837 return face
838 .opacity(DISABLED_OPACITY)
839 .cursor_default()
840 .into_any_element();
841 }
842 let app = app.clone();
843 Popover::new("call-reactions-popover")
844 .anchor(Anchor::BottomLeft)
845 .offset(px(10.))
846 .trigger(
847 Button::new("call-reactions")
848 .ghost()
849 .p_0()
850 .size(px(CONTROL_SIZE))
851 .rounded_full()
852 .child(face),
853 )
854 .content(move |_, _, cx| {
855 let popover = cx.entity().downgrade();
856 h_flex()
857 .id("call-reactions-row")
858 .gap(px(4.))
859 .children(Reaction::ALL.into_iter().map(|reaction| {
860 let app = app.clone();
861 let popover = popover.clone();
862 div()
863 .id(ElementId::Name(reaction.name().to_owned().into()))
864 .size(px(REACTION_CELL))
865 .flex()
866 .items_center()
867 .justify_center()
868 .rounded(px(8.))
869 .text_size(px(24.))
870 .cursor_pointer()
871 .hover(|cell| cell.bg(theme::border_strong()))
872 .child(reaction_glyph(&reaction))
873 .on_click(move |_, window, cx| {
874 app.update(cx, |state, cx| state.send_call_reaction(reaction.clone(), cx));
875 popover
876 .update(cx, |state, cx| state.dismiss(window, cx))
877 .ok();
878 })
879 }))
880 })
881 .into_any_element()
882}
883
884fn has_leave_menu(model: &CallModel) -> bool {
885 model.kind == CallKind::Meeting
886 && (model.can_end_meeting || (model.can_lower_hands() && model.any_hand_raised()))
887}
888
889fn leave_menu(app: &Entity<AppState>, model: &CallModel) -> impl IntoElement {
890 let end_app = app.clone();
891 let can_end = model.can_end_meeting;
892 let lower_app = app.clone();
893 let can_lower_all = model.can_lower_hands() && model.any_hand_raised();
894 Button::new("call-leave-menu")
895 .ghost()
896 .p_0()
897 .size(px(CONTROL_SIZE))
898 .rounded_full()
899 .child(round_control(
900 "call-leave-menu-face",
901 IconName::ChevronUp,
902 theme::surface_raised(),
903 theme::text(),
904 ))
905 .dropdown_menu_with_anchor(Anchor::BottomRight, move |popup, _, _| {
906 let end_app = end_app.clone();
907 let lower_app = lower_app.clone();
908 let popup = popup.min_w(px(MENU_WIDTH));
909 let popup = if can_lower_all {
910 popup.item(
911 PopupMenuItem::new("Lower all hands").on_click(move |_, _, cx| {
912 lower_app.update(cx, |state, cx| state.lower_all_call_hands(cx))
913 }),
914 )
915 } else {
916 popup
917 };
918 if can_end {
919 popup.item(
920 PopupMenuItem::new("End meeting for everyone")
921 .icon(IconName::PhoneOff)
922 .on_click(move |_, _, cx| {
923 end_app.update(cx, |state, cx| state.end_meeting_for_all(cx))
924 }),
925 )
926 } else {
927 popup
928 }
929 })
930}
931
932pub(super) fn device_items(
933 entries: Vec<DeviceEntry>,
934 selected: &calling::DeviceChoice,
935 pick: impl Fn(calling::DeviceChoice, &mut App) + Clone + 'static,
936) -> Vec<PopupMenuItem> {
937 entries
938 .into_iter()
939 .map(|entry| {
940 let pick = pick.clone();
941 let choice = entry.choice.clone();
942 PopupMenuItem::new(entry.label)
943 .checked(&entry.choice == selected)
944 .on_click(move |_, _, cx| pick(choice.clone(), cx))
945 })
946 .collect()
947}
948
949fn devices_menu(
950 popup: PopupMenu,
951 app: &Entity<AppState>,
952 model: &CallModel,
953 mic: MicSettings,
954) -> PopupMenu {
955 if model.audio_off {
956 return popup.item(PopupMenuItem::new(AUDIO_OFF_HINT).disabled(true));
957 }
958 let input_app = app.clone();
959 let output_app = app.clone();
960 let inputs = device_items(
961 model.devices.input_entries(),
962 &model.input,
963 move |choice, cx| {
964 input_app.update(cx, |state, cx| state.select_call_input(choice, cx));
965 },
966 );
967 let outputs = device_items(
968 model.devices.output_entries(),
969 &model.output,
970 move |choice, cx| {
971 output_app.update(cx, |state, cx| state.select_call_output(choice, cx));
972 },
973 );
974 let mut popup = popup
975 .min_w(px(MENU_WIDTH))
976 .item(PopupMenuItem::label("Microphone"));
977 if model.listen_only {
978 popup = popup.item(PopupMenuItem::new(NO_MICROPHONE_HINT).disabled(true));
979 } else {
980 for item in inputs {
981 popup = popup.item(item);
982 }
983 }
984 popup = popup
985 .separator()
986 .item(PopupMenuItem::label(NOISE_SUPPRESSION_LABEL));
987 for level in NoiseSuppression::ALL {
988 let level_app = app.clone();
989 popup = popup.item(
990 PopupMenuItem::new(level.label())
991 .checked(level == mic.noise_suppression)
992 .disabled(mic.music_mode)
993 .on_click(move |_, _, cx| {
994 level_app.update(cx, |state, cx| {
995 let settings = MicSettings {
996 noise_suppression: level,
997 ..state.call_mic
998 };
999 state.set_call_mic(settings, cx)
1000 })
1001 }),
1002 );
1003 }
1004 popup = popup
1005 .item(music_mode_item(app, mic))
1006 .separator()
1007 .item(PopupMenuItem::label("Speaker"));
1008 for item in outputs {
1009 popup = popup.item(item);
1010 }
1011 popup
1012}
1013
1014fn mic_menu_button(app: &Entity<AppState>, model: &CallModel, mic: MicSettings) -> impl IntoElement {
1015 let app = app.clone();
1016 let model = model.clone();
1017 chevron_button("call-mic-menu", "call-mic-menu-face")
1018 .dropdown_menu_with_anchor(Anchor::BottomLeft, move |popup, _, _| {
1019 devices_menu(popup, &app, &model, mic)
1020 })
1021}
1022
1023pub(super) fn person_tile(
1024 app: &Entity<AppState>,
1025 state: &AppState,
1026 model: &CallModel,
1027 remote: &Tile,
1028 size: TileSize,
1029 now: Instant,
1030) -> AnyElement {
1031 let element = plain_person_tile(state, model, remote, size, now);
1032 with_tile_menu(app, model, &remote.mri, &remote.name, false, element)
1033}
1034
1035pub(super) fn plain_person_tile(
1036 state: &AppState,
1037 model: &CallModel,
1038 remote: &Tile,
1039 size: TileSize,
1040 now: Instant,
1041) -> AnyElement {
1042 let extras = TileExtras {
1043 hand: remote.hand.map(|rank| model.hand_position(rank)),
1044 own: false,
1045 reaction: model
1046 .chip_of(&remote.mri, now)
1047 .map(|chip| (chip.reaction.clone(), chip.serial)),
1048 spotlight: remote.spotlight.is_some(),
1049 pinned: model.is_pinned(&remote.mri),
1050 fitted: model.is_fitted(&remote.mri),
1051 };
1052 person_tile_body(state, model, remote, size, now, &extras)
1053}
1054
1055fn person_tile_body(
1056 state: &AppState,
1057 model: &CallModel,
1058 remote: &Tile,
1059 size: TileSize,
1060 now: Instant,
1061 extras: &TileExtras,
1062) -> AnyElement {
1063 let video = state
1064 .call
1065 .as_ref()
1066 .filter(|_| remote.has_video || model.is_one_to_one())
1067 .and_then(|call| {
1068 call.pictures
1069 .live(&VideoKey::Person(remote.mri.clone()), now)
1070 });
1071 if let Some(image) = video {
1072 return video_tile(
1073 size,
1074 image,
1075 &remote.name,
1076 model.tile_speaking(remote),
1077 remote.muted,
1078 extras,
1079 )
1080 .into_any_element();
1081 }
1082 let waiting = remote.state == TileState::Invited;
1083 let avatar = person_avatar(
1084 &state.directory,
1085 remote.user_id.as_deref(),
1086 &remote.name,
1087 size.avatar,
1088 );
1089 let caption = model.tile_caption(remote).map(|text| {
1090 let label = div()
1091 .text_size(px(12.))
1092 .text_color(theme::text_muted())
1093 .child(text);
1094 if waiting {
1095 blinking(label)
1096 } else {
1097 label.into_any_element()
1098 }
1099 });
1100 tile(
1101 size,
1102 avatar,
1103 &remote.name,
1104 model.tile_speaking(remote),
1105 remote.muted,
1106 caption,
1107 extras,
1108 )
1109 .into_any_element()
1110}
1111
1112pub(super) fn own_tile(
1113 app: &Entity<AppState>,
1114 state: &AppState,
1115 model: &CallModel,
1116 size: TileSize,
1117 now: Instant,
1118) -> AnyElement {
1119 let own_mri = model.own_mri.clone().unwrap_or_default();
1120 let element = plain_own_tile(state, model, size, now);
1121 if own_mri.is_empty() {
1122 return element;
1123 }
1124 with_tile_menu(app, model, &own_mri, "You", true, element)
1125}
1126
1127pub(super) fn plain_own_tile(
1128 state: &AppState,
1129 model: &CallModel,
1130 size: TileSize,
1131 now: Instant,
1132) -> AnyElement {
1133 let own_mri = model.own_mri.as_deref().unwrap_or_default();
1134 let extras = TileExtras {
1135 hand: model.own_hand.map(|rank| model.hand_position(rank)),
1136 own: true,
1137 reaction: model.own_chip(now).map(|chip| (chip.reaction.clone(), chip.serial)),
1138 spotlight: model.own_spotlight.is_some(),
1139 pinned: model.is_pinned(own_mri),
1140 fitted: false,
1141 };
1142 own_tile_body(state, model, size, now, &extras)
1143}
1144
1145fn own_tile_body(
1146 state: &AppState,
1147 model: &CallModel,
1148 size: TileSize,
1149 now: Instant,
1150 extras: &TileExtras,
1151) -> AnyElement {
1152 let me = state.directory.me.as_ref();
1153 let self_view = state
1154 .call
1155 .as_ref()
1156 .and_then(|call| call.pictures.live(&VideoKey::LocalCamera, now));
1157 if let Some(image) = self_view {
1158 return video_tile(
1159 size,
1160 image,
1161 "You",
1162 model.local_speaking,
1163 model.muted,
1164 extras,
1165 )
1166 .into_any_element();
1167 }
1168 let avatar = person_avatar(
1169 &state.directory,
1170 me.map(|person| person.user_id.as_str()),
1171 me.map_or("You", |person| person.display_name.as_str()),
1172 size.avatar,
1173 );
1174 tile(
1175 size,
1176 avatar,
1177 "You",
1178 model.local_speaking,
1179 model.muted,
1180 None,
1181 extras,
1182 )
1183 .into_any_element()
1184}
1185
1186fn folded_controls(state: &AppState, call: &ActiveCall, fullscreen: bool) -> FoldedControls {
1187 let model = &call.model;
1188 let has_more = model.kind != CallKind::Test;
1189 if !has_more {
1190 return FoldedControls::default();
1191 }
1192 let mut present = vec![Foldable::View];
1193 if model.has_reaction_controls() {
1194 present.extend([Foldable::Reactions, Foldable::RaiseHand]);
1195 }
1196 if model.kind != CallKind::Test {
1197 present.push(Foldable::People);
1198 }
1199 if call.chat_thread().is_some() {
1200 present.push(Foldable::Chat);
1201 }
1202 let fixed = fixed_controls_width(
1203 model.can_use_camera(),
1204 has_more,
1205 has_leave_menu(model),
1206 );
1207 FoldedControls {
1208 items: folded_for_width(measured_stage(call).0, fixed, &present),
1209 fullscreen,
1210 people_open: call.people_open,
1211 chat_open: call.chat_open,
1212 chat_unread: state.call_chat_unread(),
1213 }
1214}
1215
1216pub fn render_call_view(
1217 app: &Entity<AppState>,
1218 state: &AppState,
1219 chat: Option<AnyView>,
1220 fullscreen: bool,
1221 island_width: f32,
1222) -> Option<AnyElement> {
1223 let call = state.call.as_ref()?;
1224 let model = &call.model;
1225 let now = Instant::now();
1226 let (status, status_color) = status_line(model, now);
1227 let header = h_flex()
1228 .w_full()
1229 .h(px(HEADER_HEIGHT))
1230 .flex_none()
1231 .px(px(20.))
1232 .gap(px(12.))
1233 .items_center()
1234 .child(icon(IconName::Phone, 18., theme::accent_text()))
1235 .child(
1236 div()
1237 .min_w_0()
1238 .truncate()
1239 .text_size(px(16.))
1240 .font_weight(FontWeight::SEMIBOLD)
1241 .child(model.title.clone()),
1242 )
1243 .child(
1244 div()
1245 .flex_none()
1246 .text_size(px(13.))
1247 .text_color(status_color)
1248 .child(status),
1249 )
1250 .children(health_indicator(model))
1251 .children(recording_chip(model))
1252 .children(lock_chip(model))
1253 .children(room_chip(model))
1254 .child(div().flex_1())
1255 .children(return_button(app, model));
1256
1257 let hold = hold_panel(app, model);
1258 let share_stage = share_stage_element(app, state, call);
1259 let region = stage_region(app, state, call, now, hold, share_stage);
1260
1261 let folded = folded_controls(state, call, fullscreen);
1262 let controls = h_flex()
1263 .w_full()
1264 .flex_none()
1265 .py(px(16.))
1266 .px(px(CONTROLS_PADDING))
1267 .gap(px(CONTROL_GAP))
1268 .items_center()
1269 .justify_center()
1270 .child(
1271 h_flex()
1272 .debug_selector(|| "shell/islands/main/call-controls/mic".into())
1273 .h(px(CONTROL_SIZE))
1274 .items_center()
1275 .rounded_full()
1276 .bg(theme::surface_raised())
1277 .child(mute_button(app, model, "call-mute", CONTROL_SIZE))
1278 .child(mic_menu_button(app, model, state.call_mic)),
1279 )
1280 .child(
1281 h_flex()
1282 .h(px(CONTROL_SIZE))
1283 .items_center()
1284 .rounded_full()
1285 .bg(theme::surface_raised())
1286 .child(camera_button(app, model))
1287 .children(camera_menu_button(app, model, CameraMenu::of(state))),
1288 )
1289 .child(share_button(
1290 app,
1291 model,
1292 ShareOptions::of(state),
1293 call.share_menu_open,
1294 ))
1295 .when(
1296 model.has_reaction_controls() && !folded.folds(Foldable::RaiseHand),
1297 |row| row.child(hand_button(app, model)),
1298 )
1299 .when(
1300 model.has_reaction_controls() && !folded.folds(Foldable::Reactions),
1301 |row| row.child(reactions_button(app, model)),
1302 )
1303 .when(!folded.folds(Foldable::View), |row| {
1304 row.child(view_button(app, model, fullscreen))
1305 })
1306 .children(more_button(app, model, &folded))
1307 .when(
1308 model.kind != CallKind::Test && !folded.folds(Foldable::People),
1309 |row| row.child(people_button(app, call.people_open, model.raised_hands())),
1310 )
1311 .when(
1312 call.chat_thread().is_some() && !folded.folds(Foldable::Chat),
1313 |row| row.child(chat_button(app, call.chat_open, state.call_chat_unread())),
1314 )
1315 .child(
1316 leave_button(app, model, "call-leave", false)
1317 .debug_selector(|| "shell/islands/main/call-controls/leave".into()),
1318 )
1319 .when(has_leave_menu(model), |row| row.child(leave_menu(app, model)));
1320
1321 let top = v_flex()
1322 .w_full()
1323 .flex_none()
1324 .child(header)
1325 .children(lobby_banner(app, model, call.lobby_list_open))
1326 .children(lock_banner(app, model))
1327 .children(health_banner(app, model))
1328 .children(sharing_banner(app, model, state.call_share_sound))
1329 .children(consult_banner(app, state));
1330
1331 let chrome_visible = call
1332 .fullscreen
1333 .is_none_or(|fullscreen| fullscreen.chrome_visible(now));
1334 let move_app = app.clone();
1335 let base = v_flex()
1336 .relative()
1337 .flex_1()
1338 .min_w_0()
1339 .h_full()
1340 .overflow_hidden()
1341 .bg(theme::surface());
1342 let column = if fullscreen {
1343 base.on_mouse_move(move |_, _, cx| {
1344 move_app.update(cx, |state, cx| state.touch_call_chrome(cx))
1345 })
1346 .when(chrome_visible, |column| {
1347 column.child(fullscreen_chrome("call-chrome-top", app, top))
1348 })
1349 .child(region)
1350 .when(chrome_visible, |column| {
1351 column.child(fullscreen_chrome("call-chrome-bottom", app, controls))
1352 })
1353 } else {
1354 base.rounded(px(10.))
1355 .child(top.debug_selector(|| "shell/islands/main/call-header".into()))
1356 .child(region)
1357 .child(controls.debug_selector(|| "shell/islands/main/call-controls".into()))
1358 }
1359 .children(captions_overlay(model, now))
1360 .children(captions_hint_chip(model))
1361 .children(push_to_talk_chip(call))
1362 .children(state.transfer_picker.clone())
1363 .children(options_dialog(app, call))
1364 .children(consent_overlay(app, model));
1365 let panels: Vec<AnyElement> = chat
1366 .map(|chat| chat_panel(app, chat))
1367 .into_iter()
1368 .chain(
1369 call.transcript_open
1370 .then(|| state.transcript_panel.clone())
1371 .flatten()
1372 .map(IntoElement::into_any_element),
1373 )
1374 .chain(people_panel(app, state, call))
1375 .collect();
1376 Some(
1377 h_flex()
1378 .relative()
1379 .when(!fullscreen, |row| {
1380 row.debug_selector(|| "shell/islands/main".into())
1381 })
1382 .flex_1()
1383 .min_w_0()
1384 .h_full()
1385 .gap(px(ISLAND_GAP))
1386 .child(column)
1387 .children(side_panels(panels, island_width))
1388 .into_any_element(),
1389 )
1390}
1391
1392fn side_panels(panels: Vec<AnyElement>, island_width: f32) -> Vec<AnyElement> {
1393 if panels.is_empty() {
1394 return panels;
1395 }
1396 let panels_width = (CHAT_PANEL_WIDTH + ISLAND_GAP) * panels.len() as f32;
1397 if island_width - panels_width >= OVERLAY_BELOW {
1398 return panels;
1399 }
1400 vec![
1401 h_flex()
1402 .absolute()
1403 .top_0()
1404 .right_0()
1405 .bottom(px(CONTROLS_HEIGHT))
1406 .gap(px(ISLAND_GAP))
1407 .w(px(panels_width.min(island_width)))
1408 .children(panels)
1409 .into_any_element(),
1410 ]
1411}
1412
1413fn fullscreen_chrome(id: &'static str, app: &Entity<AppState>, content: Div) -> Stateful<Div> {
1414 let hover_app = app.clone();
1415 div()
1416 .id(id)
1417 .w_full()
1418 .flex_none()
1419 .on_hover(move |hovered, _, cx| {
1420 hover_app.update(cx, |state, cx| state.set_call_chrome_hovered(*hovered, cx))
1421 })
1422 .child(content)
1423}
1424
1425fn chat_panel(app: &Entity<AppState>, chat: AnyView) -> AnyElement {
1426 let app = app.clone();
1427 side_panel(
1428 "call-chat-panel",
1429 "Chat",
1430 "Close the chat",
1431 move |cx| app.update(cx, |state, cx| state.toggle_call_chat(cx)),
1432 chat,
1433 )
1434 .debug_selector(|| CHAT_PANEL_TAG.into())
1435 .into_any_element()
1436}
1437
1438pub fn side_panel(
1439 panel_id: &'static str,
1440 title: &'static str,
1441 close_tooltip: &'static str,
1442 on_close: impl Fn(&mut App) + 'static,
1443 body: impl IntoElement,
1444) -> Stateful<Div> {
1445 v_flex()
1446 .id(panel_id)
1447 .w(px(CHAT_PANEL_WIDTH))
1448 .h_full()
1449 .flex_shrink(1.)
1450 .min_w_0()
1451 .rounded(px(10.))
1452 .overflow_hidden()
1453 .bg(theme::surface())
1454 .child(
1455 h_flex()
1456 .w_full()
1457 .h(px(CHAT_HEADER_HEIGHT))
1458 .flex_none()
1459 .pl(px(20.))
1460 .pr(px(12.))
1461 .items_center()
1462 .justify_between()
1463 .child(
1464 div()
1465 .text_size(px(15.))
1466 .font_weight(FontWeight::SEMIBOLD)
1467 .child(title),
1468 )
1469 .child(
1470 div()
1471 .id(ElementId::Name(format!("{panel_id}-close").into()))
1472 .size(px(28.))
1473 .flex()
1474 .items_center()
1475 .justify_center()
1476 .rounded(px(7.))
1477 .cursor_pointer()
1478 .hover(|button| button.bg(theme::row_hover()))
1479 .tooltip(move |window, cx| Tooltip::new(close_tooltip).build(window, cx))
1480 .child(icon(IconName::Close, 14., theme::text_muted()))
1481 .on_click(move |_, _, cx| on_close(cx)),
1482 ),
1483 )
1484 .child(body)
1485}