BlueGit

ict rusty-teams

feat(linux): Wayland screen share via desktop ScreenCast portal

Under Wayland, share screen or window through the portal dialog instead
of an empty thumbnail list. Cancel stays quiet; missing portal shows a
notice.

metis Joachim Mild · pushed by metis

Authored 2026-11-12 · 2 weeks ago

Hash
2470dc6c01a1e445d9b6edb944a6b2f6aadf5f87
Parent
e0c125b2
1 file changed +429 −246
crates/app/src/views/call_view.rs +429 −246
@@ -16,32 +16,32 @@ 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, in_more_menu};
20 use super::call_toolbar::{
21 GROUP_GAP, LEAVE_HEIGHT, group_divider, SPLIT_CHEVRON_WIDTH, TOOL_GAP, tool_face, tool_trigger, split_chevron,
19 use super::call_control_fold::{
20 fixed_controls_width, folded_for_width, Foldable, FoldedControls, CONTROLS_PADDING, CONTROL_GAP,
22 21 };
23 22 use super::call_extras::{
24 CameraMenu, consent_overlay, consult_banner, hold_panel, recording_chip, return_button,
25 room_chip, whiteboard_stage,
23 consent_overlay, consult_banner, hold_panel, recording_chip, return_button, room_chip,
24 whiteboard_stage, CameraMenu,
26 25 };
27 26 use super::call_health::{health_banner, health_indicator};
28 27 use super::call_layouts::stage_region;
29 use crate::call::measured_stage;
30 28 use super::call_organizer::{
31 camera_menu_button, captions_hint_chip, captions_overlay, lobby_banner,
29 camera_menu_button, captions_hint_chip, captions_overlay, chevron_button, lobby_banner,
32 30 more_button, pin_chip, spotlight_chip, with_tile_menu,
33 31 };
34 32 use super::call_people::{lock_banner, lock_chip, options_dialog, people_button, people_panel};
35 use super::call_stage::{POP_OUT_TOOLTIP, StageMode, popped_placeholder, render_stage};
33 use super::call_stage::{popped_placeholder, render_stage, StageMode, WAITING_TEXT};
36 34 use super::call_view_menu::view_button;
37 use app_ui_kit::layout::ISLAND_GAP;
38 use super::widgets::{Corner, corner_badge, count_badge, icon};
35 use super::widgets::{corner_badge, count_badge, icon, Corner};
39 36 use crate::app_state::AppState;
40 use crate::call::REACTION_SHOWN;
37 use crate::call::measured_stage;
38 use crate::call::model::ShareMenuEntry;
41 39 use crate::call::TileSize;
40 use crate::call::REACTION_SHOWN;
42 41 use crate::call::{ActiveCall, CallKind, CallModel, Tile, TileState};
43 42 use crate::rows::reaction_glyph as chat_reaction_glyph;
44 43 use crate::theme;
44 use app_ui_kit::layout::ISLAND_GAP;
45 45
46 46 const HEADER_HEIGHT: f32 = 60.;
47 47 const RING_WIDTH: f32 = 3.;
@@ -64,7 +64,6 @@ pub const NO_CAMERA_HINT: &str = "No camera found";
64 64 pub const NO_SHARE_HINT: &str = "Sharing starts once the call is connected";
65 65 pub const NO_WINDOWS_HINT: &str = "No windows found";
66 66 pub(super) const BANNER_HEIGHT: f32 = 40.;
67 const MAX_WINDOW_ITEMS: usize = 12;
68 67 pub const SHARE_THUMBNAIL_TAG: &str = "call/share-menu/thumbnail";
69 68 const SCREEN_THUMBNAIL: (f32, f32) = (128., 72.);
70 69 const WINDOW_THUMBNAIL: (f32, f32) = (96., 54.);
@@ -73,8 +72,7 @@ const THUMBNAIL_ICON: f32 = 22.;
73 72 pub const LOBBY_TEXT: &str = "Waiting in the lobby...";
74 73 pub(super) const CHAT_PANEL_WIDTH: f32 = 320.;
75 74 pub(super) const OVERLAY_BELOW: f32 = 720.;
76 const HEADER_END_PADDING: f32 = 8.;
77 const LEAVE_RADIUS: f32 = 6.;
75 const CONTROLS_HEIGHT: f32 = 2. * 16. + CONTROL_SIZE;
78 76 const CHAT_HEADER_HEIGHT: f32 = 48.;
79 77 const REACTION_RISE: f32 = 24.;
80 78 const REACTION_FADE_FROM: f32 = 0.75;
@@ -90,8 +88,13 @@ const PUSH_TO_TALK_TOP: f32 = 12.;
90 88
91 89 pub fn reaction_glyph(reaction: &Reaction) -> String {
92 90 match reaction {
91 Reaction::Like => "\u{1F44D}".to_owned(),
92 // Keep VS16 so the heart stays emoji-style, not a text outline.
93 Reaction::Heart => "\u{2764}\u{FE0F}".to_owned(),
93 94 Reaction::Applause => "\u{1F44F}".to_owned(),
94 other => chat_reaction_glyph(other.name()),
95 Reaction::Laugh => "\u{1F606}".to_owned(),
96 Reaction::Surprised => "\u{1F62E}".to_owned(),
97 Reaction::Other(name) => chat_reaction_glyph(name),
95 98 }
96 99 }
97 100
@@ -143,6 +146,7 @@ fn reaction_chip(reaction: Reaction, serial: u64) -> AnyElement {
143 146 .rounded_full()
144 147 .bg(theme::popup())
145 148 .text_size(px(if emoji { 20. } else { 13. }))
149 .when(emoji, |chip| chip.font_family(theme::EMOJI_FONT_FAMILY))
146 150 .child(glyph)
147 151 .with_animation(
148 152 ("call-reaction", serial as usize),
@@ -251,9 +255,23 @@ struct NamePlate {
251 255
252 256 fn name_plate_metrics(size: TileSize) -> NamePlate {
253 257 if size.height < COMPACT_PLATE_BELOW {
254 NamePlate { inset: 4., padding_x: 6., padding_y: 2., radius: 4., text_size: 11., max_width_share: 0.6 }
258 NamePlate {
259 inset: 4.,
260 padding_x: 6.,
261 padding_y: 2.,
262 radius: 4.,
263 text_size: 11.,
264 max_width_share: 0.6,
265 }
255 266 } else {
256 NamePlate { inset: 8., padding_x: 8., padding_y: 4., radius: 6., text_size: 12., max_width_share: 1. }
267 NamePlate {
268 inset: 8.,
269 padding_x: 8.,
270 padding_y: 4.,
271 radius: 6.,
272 text_size: 12.,
273 max_width_share: 1.,
274 }
257 275 }
258 276 }
259 277
@@ -263,7 +281,9 @@ fn name_plate(size: TileSize, name: &str) -> Div {
263 281 .absolute()
264 282 .left(px(plate.inset))
265 283 .bottom(px(plate.inset))
266 .max_w(px(((size.width - 3. * plate.inset) * plate.max_width_share).max(0.)))
284 .max_w(px(((size.width - 3. * plate.inset)
285 * plate.max_width_share)
286 .max(0.)))
267 287 .truncate()
268 288 .px(px(plate.padding_x))
269 289 .py(px(plate.padding_y))
@@ -385,19 +405,7 @@ pub fn mute_button(
385 405 } else {
386 406 (IconName::Mic, theme::surface_raised(), theme::text())
387 407 };
388 mic_action(round_control(id, glyph, background, foreground).size(px(size)), app, model)
389 }
390
391 fn toolbar_mic(app: &Entity<AppState>, model: &CallModel) -> Stateful<Div> {
392 let glyph = if model.muted {
393 IconName::MicOff
394 } else {
395 IconName::Mic
396 };
397 mic_action(tool_face("call-mute", glyph, "Mic", false), app, model)
398 }
399
400 fn mic_action(button: Stateful<Div>, app: &Entity<AppState>, model: &CallModel) -> Stateful<Div> {
408 let button = round_control(id, glyph, background, foreground).size(px(size));
401 409 if !model.can_unmute() {
402 410 let hint = if model.audio_off {
403 411 AUDIO_OFF_HINT
@@ -430,8 +438,8 @@ pub fn leave_button(
430 438 let app = app.clone();
431 439 h_flex()
432 440 .id(id)
433 .h(px(if compact { 28. } else { LEAVE_HEIGHT }))
434 .px(px(if compact { 10. } else { 14. }))
441 .h(px(if compact { 28. } else { CONTROL_SIZE }))
442 .px(px(if compact { 10. } else { 20. }))
435 443 .gap(px(8.))
436 444 .flex_none()
437 445 .items_center()
@@ -439,13 +447,13 @@ pub fn leave_button(
439 447 .rounded_full()
440 448 .bg(theme::red())
441 449 .text_color(theme::white())
442 .text_size(px(if compact { 12. } else { 13. }))
450 .text_size(px(if compact { 12. } else { 14. }))
443 451 .font_weight(FontWeight::SEMIBOLD)
444 452 .cursor_pointer()
445 453 .hover(|button| button.opacity(0.85))
446 454 .child(icon(
447 455 IconName::PhoneOff,
448 if compact { 14. } else { 16. },
456 if compact { 14. } else { 18. },
449 457 theme::white(),
450 458 ))
451 459 .child(label)
@@ -455,7 +463,11 @@ pub fn leave_button(
455 463 })
456 464 }
457 465
458 fn share_stage_element(app: &Entity<AppState>, state: &AppState, call: &ActiveCall) -> Option<AnyElement> {
466 fn share_stage_element(
467 app: &Entity<AppState>,
468 state: &AppState,
469 call: &ActiveCall,
470 ) -> Option<AnyElement> {
459 471 if call.share_stage.popped && call.model.screen_sharer.is_some() {
460 472 return Some(popped_placeholder(app));
461 473 }
@@ -468,19 +480,7 @@ pub(super) fn camera_button(app: &Entity<AppState>, model: &CallModel) -> Statef
468 480 } else {
469 481 (IconName::VideoOff, theme::surface_raised(), theme::text())
470 482 };
471 camera_action(round_control("call-camera", glyph, background, foreground), app, model)
472 }
473
474 fn toolbar_camera(app: &Entity<AppState>, model: &CallModel) -> Stateful<Div> {
475 let glyph = if model.camera_on {
476 IconName::Video
477 } else {
478 IconName::VideoOff
479 };
480 camera_action(tool_face("call-camera", glyph, "Camera", false), app, model)
481 }
482
483 fn camera_action(button: Stateful<Div>, app: &Entity<AppState>, model: &CallModel) -> Stateful<Div> {
483 let button = round_control("call-camera", glyph, background, foreground);
484 484 if !model.can_use_camera() {
485 485 return button
486 486 .opacity(DISABLED_OPACITY)
@@ -550,7 +550,9 @@ fn standout_switch_item(app: &Entity<AppState>, standout: bool, camera_on: bool)
550 550 })
551 551 })
552 552 .disabled(!camera_on)
553 .on_click(move |_, _, cx| app.update(cx, |state, cx| state.set_call_share_standout(!standout, cx)))
553 .on_click(move |_, _, cx| {
554 app.update(cx, |state, cx| state.set_call_share_standout(!standout, cx))
555 })
554 556 }
555 557
556 558 fn music_mode_item(app: &Entity<AppState>, mic: MicSettings) -> PopupMenuItem {
@@ -624,6 +626,72 @@ fn share_items(
624 626 model: &CallModel,
625 627 options: ShareOptions,
626 628 ) -> PopupMenu {
629 <<<<<<< ours
630 let single_screen = model.screens().len() == 1;
631 let mut screen_index = 0usize;
632 let mut separated = false;
633 let mut popup = popup.min_w(px(SHARE_MENU_WIDTH));
634 for entry in model.share_menu_entries() {
635 popup = match entry {
636 ShareMenuEntry::Sound => popup.item(sound_switch_item(app, options.sound)),
637 ShareMenuEntry::Motion => popup.item(motion_switch_item(app, options.motion)),
638 ShareMenuEntry::Standout => {
639 popup.item(standout_switch_item(app, options.standout, model.camera_on))
640 }
641 ShareMenuEntry::Portal(kind) => {
642 if !separated {
643 popup = popup.separator();
644 separated = true;
645 }
646 let label = match kind {
647 ShareKind::Screen => "Share entire screen",
648 ShareKind::Window => "Share a window",
649 };
650 let app = app.clone();
651 popup.item(PopupMenuItem::new(label).on_click(move |_, _, cx| {
652 app.update(cx, |state, cx| state.start_portal_share(kind, cx))
653 }))
654 }
655 ShareMenuEntry::Source(source) => {
656 if !separated {
657 popup = popup.separator();
658 separated = true;
659 }
660 let (label, thumbnail, icon, size) = if source.kind == ShareKind::Screen {
661 screen_index += 1;
662 let label = if single_screen {
663 "Share entire screen".to_owned()
664 } else {
665 format!("Share screen {screen_index}")
666 };
667 (
668 label,
669 model.share_thumbnail(&source),
670 IconName::Monitor,
671 SCREEN_THUMBNAIL,
672 )
673 } else {
674 (
675 source.label(),
676 model.share_thumbnail(&source),
677 IconName::AppWindow,
678 WINDOW_THUMBNAIL,
679 )
680 };
681 let app = app.clone();
682 popup.item(share_source_item(label, thumbnail, icon, size).on_click(
683 move |_, _, cx| {
684 app.update(cx, |state, cx| state.start_call_share(source.clone(), cx))
685 },
686 ))
687 }
688 ShareMenuEntry::WindowHeader => popup
689 .separator()
690 .item(PopupMenuItem::label("Share a window...")),
691 ShareMenuEntry::NoWindows => {
692 popup.item(PopupMenuItem::new(NO_WINDOWS_HINT).disabled(true))
693 }
694 =======
627 695 let mut popup = popup
628 696 .min_w(px(SHARE_MENU_WIDTH))
629 697 .item(sound_switch_item(app, options.sound))
@@ -654,33 +722,8 @@ fn share_items(
654 722 "Share entire screen".to_owned()
655 723 } else {
656 724 format!("Share screen {}", index + 1)
725 >>>>>>> theirs
657 726 };
658 let thumbnail = model.share_thumbnail(source);
659 let source = source.clone();
660 let app = app.clone();
661 popup = popup.item(
662 share_source_item(label, thumbnail, IconName::Monitor, SCREEN_THUMBNAIL).on_click(
663 move |_, _, cx| app.update(cx, |state, cx| state.start_call_share(source.clone(), cx)),
664 ),
665 );
666 }
667 popup = popup
668 .separator()
669 .item(PopupMenuItem::label("Share a window..."));
670 let windows = model.windows();
671 if windows.is_empty() {
672 return popup.item(PopupMenuItem::new(NO_WINDOWS_HINT).disabled(true));
673 }
674 for source in windows.into_iter().take(MAX_WINDOW_ITEMS) {
675 let label = source.label();
676 let thumbnail = model.share_thumbnail(source);
677 let source = source.clone();
678 let app = app.clone();
679 popup = popup.item(
680 share_source_item(label, thumbnail, IconName::AppWindow, WINDOW_THUMBNAIL).on_click(
681 move |_, _, cx| app.update(cx, |state, cx| state.start_call_share(source.clone(), cx)),
682 ),
683 );
684 727 }
685 728 popup
686 729 }
@@ -733,7 +776,12 @@ fn share_button(
733 776 ) -> AnyElement {
734 777 if model.local_share.is_some() {
735 778 let app = app.clone();
736 return tool_face("call-share-stop", IconName::ScreenShareOff, "Stop", true)
779 return round_control(
780 "call-share-stop",
781 IconName::ScreenShareOff,
782 theme::accent(),
783 theme::on_accent(),
784 )
737 785 .tooltip(|window, cx| Tooltip::new("Stop sharing").build(window, cx))
738 786 .on_click(move |_, _, cx| {
739 787 cx.stop_propagation();
@@ -741,7 +789,12 @@ fn share_button(
741 789 })
742 790 .into_any_element();
743 791 }
744 let face = tool_face("call-share-face", IconName::ScreenShare, "Share", false);
792 let face = round_control(
793 "call-share-face",
794 IconName::ScreenShare,
795 theme::surface_raised(),
796 theme::text(),
797 );
745 798 if !model.can_share() {
746 799 return face
747 800 .opacity(DISABLED_OPACITY)
@@ -752,8 +805,13 @@ fn share_button(
752 805 let app = app.clone();
753 806 let open_app = app.clone();
754 807 let model = model.clone();
755 tool_trigger("call-share", face)
756 .dropdown_menu_with_anchor(Anchor::TopRight, move |popup, _, _| {
808 Button::new("call-share")
809 .ghost()
810 .p_0()
811 .size(px(CONTROL_SIZE))
812 .rounded_full()
813 .child(face)
814 .dropdown_menu_with_anchor(Anchor::BottomLeft, move |popup, _, _| {
757 815 share_items(popup, &app, &model, options)
758 816 })
759 817 .open(menu_open)
@@ -826,7 +884,12 @@ fn sharing_banner(app: &Entity<AppState>, model: &CallModel, sound: bool) -> Opt
826 884
827 885 fn chat_button(app: &Entity<AppState>, open: bool, unread: u32) -> Stateful<Div> {
828 886 let app = app.clone();
829 tool_face("call-chat", IconName::MessageCircle, "Chat", open)
887 let (background, foreground) = if open {
888 (theme::accent(), theme::on_accent())
889 } else {
890 (theme::surface_raised(), theme::text())
891 };
892 round_control("call-chat", IconName::MessageCircle, background, foreground)
830 893 .relative()
831 894 .tooltip(move |window, cx| {
832 895 Tooltip::new(if open {
@@ -842,9 +905,41 @@ fn chat_button(app: &Entity<AppState>, open: bool, unread: u32) -> Stateful<Div>
842 905 .on_click(move |_, _, cx| app.update(cx, |state, cx| state.toggle_call_chat(cx)))
843 906 }
844 907
845 fn reactions_button(app: &Entity<AppState>, model: &CallModel) -> AnyElement {
908 fn hand_button(app: &Entity<AppState>, model: &CallModel) -> Stateful<Div> {
846 909 let raised = model.own_hand.is_some();
847 let face = tool_face("call-reactions-face", IconName::FaceSlightlySmiling, "React", raised);
910 let background = if raised {
911 theme::accent()
912 } else {
913 theme::surface_raised()
914 };
915 let foreground = if raised {
916 theme::on_accent()
917 } else {
918 theme::text()
919 };
920 let button = control_shell("call-hand", background).child(icon(
921 IconName::Hand,
922 CONTROL_ICON,
923 foreground,
924 ));
925 let tooltip = if raised { "Lower hand" } else { "Raise hand" };
926 let button = button.tooltip(move |window, cx| Tooltip::new(tooltip).build(window, cx));
927 if !model.can_react() {
928 return button.opacity(DISABLED_OPACITY).cursor_default();
929 }
930 let app = app.clone();
931 button.on_click(move |_, _, cx| {
932 cx.stop_propagation();
933 app.update(cx, |state, cx| state.toggle_call_hand(cx));
934 })
935 }
936
937 fn reactions_button(app: &Entity<AppState>, model: &CallModel) -> AnyElement {
938 let face = control_shell("call-reactions-face", theme::surface_raised()).child(icon(
939 IconName::FaceSlightlySmiling,
940 CONTROL_ICON,
941 theme::text(),
942 ));
848 943 if !model.can_react() {
849 944 return face
850 945 .opacity(DISABLED_OPACITY)
@@ -853,14 +948,19 @@ fn reactions_button(app: &Entity<AppState>, model: &CallModel) -> AnyElement {
853 948 }
854 949 let app = app.clone();
855 950 Popover::new("call-reactions-popover")
856 .anchor(Anchor::TopRight)
857 .offset(px(6.))
858 .trigger(tool_trigger("call-reactions", face))
951 .anchor(Anchor::BottomLeft)
952 .offset(px(10.))
953 .trigger(
954 Button::new("call-reactions")
955 .ghost()
956 .p_0()
957 .size(px(CONTROL_SIZE))
958 .rounded_full()
959 .child(face),
960 )
859 961 .content(move |_, _, cx| {
860 962 let popover = cx.entity().downgrade();
861 let hand_app = app.clone();
862 let hand_popover = popover.clone();
863 let reactions = h_flex()
963 h_flex()
864 964 .id("call-reactions-row")
865 965 .gap(px(4.))
866 966 .children(Reaction::ALL.into_iter().map(|reaction| {
@@ -874,68 +974,23 @@ fn reactions_button(app: &Entity<AppState>, model: &CallModel) -> AnyElement {
874 974 .justify_center()
875 975 .rounded(px(8.))
876 976 .text_size(px(24.))
977 .font_family(theme::EMOJI_FONT_FAMILY)
877 978 .cursor_pointer()
878 979 .hover(|cell| cell.bg(theme::border_strong()))
879 980 .child(reaction_glyph(&reaction))
880 981 .on_click(move |_, window, cx| {
881 app.update(cx, |state, cx| state.send_call_reaction(reaction.clone(), cx));
982 app.update(cx, |state, cx| {
983 state.send_call_reaction(reaction.clone(), cx)
984 });
882 985 popover
883 986 .update(cx, |state, cx| state.dismiss(window, cx))
884 987 .ok();
885 988 })
886 }));
887 v_flex()
888 .gap(px(6.))
889 .child(reactions)
890 .child(
891 h_flex()
892 .id("call-hand")
893 .h(px(36.))
894 .px(px(10.))
895 .gap(px(8.))
896 .items_center()
897 .rounded(px(8.))
898 .cursor_pointer()
899 .when(raised, |row| row.bg(theme::accent_soft()))
900 .hover(|row| row.bg(theme::border_strong()))
901 .child(icon(IconName::Hand, 18., if raised { theme::accent_text() } else { theme::text() }))
902 .child(div().text_size(px(13.)).child(if raised { "Lower hand" } else { "Raise hand" }))
903 .on_click(move |_, window, cx| {
904 hand_app.update(cx, |state, cx| state.toggle_call_hand(cx));
905 hand_popover
906 .update(cx, |state, cx| state.dismiss(window, cx))
907 .ok();
908 }),
909 )
989 }))
910 990 })
911 991 .into_any_element()
912 992 }
913 993
914 fn pop_out_tool(app: &Entity<AppState>) -> Stateful<Div> {
915 let app = app.clone();
916 tool_face("call-pop-out", IconName::ExternalLink, POP_OUT_TOOLTIP, false)
917 .on_click(move |_, _, cx| app.update(cx, |state, cx| state.pop_out_stage(cx)))
918 }
919
920 fn shows_pop_out(call: &ActiveCall) -> bool {
921 call.model.screen_sharer.is_some() && !call.share_stage.popped
922 }
923
924 fn leave_group(app: &Entity<AppState>, model: &CallModel) -> AnyElement {
925 let leave = leave_button(app, model, "call-leave", false)
926 .rounded(px(LEAVE_RADIUS))
927 .debug_selector(|| "shell/islands/main/call-header/leave".into());
928 if !has_leave_menu(model) {
929 return leave.into_any_element();
930 }
931 h_flex()
932 .flex_none()
933 .gap(px(1.))
934 .child(leave.rounded_r(px(0.)))
935 .child(leave_menu(app, model))
936 .into_any_element()
937 }
938
939 994 fn has_leave_menu(model: &CallModel) -> bool {
940 995 model.kind == CallKind::Meeting
941 996 && (model.can_end_meeting || (model.can_lower_hands() && model.any_hand_raised()))
@@ -949,23 +1004,15 @@ fn leave_menu(app: &Entity<AppState>, model: &CallModel) -> impl IntoElement {
949 1004 Button::new("call-leave-menu")
950 1005 .ghost()
951 1006 .p_0()
952 .w(px(SPLIT_CHEVRON_WIDTH + 4.))
953 .h(px(LEAVE_HEIGHT))
954 .rounded_r(px(LEAVE_RADIUS))
955 .child(
956 div()
957 .id("call-leave-menu-face")
958 .size_full()
959 .flex()
960 .items_center()
961 .justify_center()
962 .rounded_r(px(LEAVE_RADIUS))
963 .bg(theme::red())
964 .cursor_pointer()
965 .hover(|face| face.opacity(0.85))
966 .child(icon(IconName::ChevronDown, 12., theme::white())),
967 )
968 .dropdown_menu_with_anchor(Anchor::TopRight, move |popup, _, _| {
1007 .size(px(CONTROL_SIZE))
1008 .rounded_full()
1009 .child(round_control(
1010 "call-leave-menu-face",
1011 IconName::ChevronUp,
1012 theme::surface_raised(),
1013 theme::text(),
1014 ))
1015 .dropdown_menu_with_anchor(Anchor::BottomRight, move |popup, _, _| {
969 1016 let end_app = end_app.clone();
970 1017 let lower_app = lower_app.clone();
971 1018 let popup = popup.min_w(px(MENU_WIDTH));
@@ -1074,11 +1121,15 @@ fn devices_menu(
1074 1121 popup
1075 1122 }
1076 1123
1077 fn mic_menu_button(app: &Entity<AppState>, model: &CallModel, mic: MicSettings) -> impl IntoElement {
1124 fn mic_menu_button(
1125 app: &Entity<AppState>,
1126 model: &CallModel,
1127 mic: MicSettings,
1128 ) -> impl IntoElement {
1078 1129 let app = app.clone();
1079 1130 let model = model.clone();
1080 split_chevron("call-mic-menu", "call-mic-menu-face")
1081 .dropdown_menu_with_anchor(Anchor::TopRight, move |popup, _, _| {
1131 chevron_button("call-mic-menu", "call-mic-menu-face")
1132 .dropdown_menu_with_anchor(Anchor::BottomLeft, move |popup, _, _| {
1082 1133 devices_menu(popup, &app, &model, mic)
1083 1134 })
1084 1135 }
@@ -1197,7 +1248,9 @@ pub(super) fn plain_own_tile(
1197 1248 let extras = TileExtras {
1198 1249 hand: model.own_hand.map(|rank| model.hand_position(rank)),
1199 1250 own: true,
1200 reaction: model.own_chip(now).map(|chip| (chip.reaction.clone(), chip.serial)),
1251 reaction: model
1252 .own_chip(now)
1253 .map(|chip| (chip.reaction.clone(), chip.serial)),
1201 1254 spotlight: model.own_spotlight.is_some(),
1202 1255 pinned: model.is_pinned(own_mri),
1203 1256 fitted: false,
@@ -1252,9 +1305,9 @@ fn folded_controls(state: &AppState, call: &ActiveCall, fullscreen: bool) -> Fol
1252 1305 if !has_more {
1253 1306 return FoldedControls::default();
1254 1307 }
1255 let mut present = Vec::new();
1308 let mut present = vec![Foldable::View];
1256 1309 if model.has_reaction_controls() {
1257 present.push(Foldable::Reactions);
1310 present.extend([Foldable::Reactions, Foldable::RaiseHand]);
1258 1311 }
1259 1312 if model.kind != CallKind::Test {
1260 1313 present.push(Foldable::People);
@@ -1262,14 +1315,9 @@ fn folded_controls(state: &AppState, call: &ActiveCall, fullscreen: bool) -> Fol
1262 1315 if call.chat_thread().is_some() {
1263 1316 present.push(Foldable::Chat);
1264 1317 }
1265 let fixed = fixed_controls_width(
1266 model.can_use_camera(),
1267 has_more,
1268 has_leave_menu(model),
1269 shows_pop_out(call),
1270 );
1318 let fixed = fixed_controls_width(model.can_use_camera(), has_more, has_leave_menu(model));
1271 1319 FoldedControls {
1272 items: in_more_menu(folded_for_width(measured_stage(call).0, fixed, &present)),
1320 items: folded_for_width(measured_stage(call).0, fixed, &present),
1273 1321 fullscreen,
1274 1322 people_open: call.people_open,
1275 1323 chat_open: call.chat_open,
@@ -1292,14 +1340,7 @@ pub fn render_call_view(
1292 1340 .w_full()
1293 1341 .h(px(HEADER_HEIGHT))
1294 1342 .flex_none()
1295 .pl(px(20.))
1296 .pr(px(HEADER_END_PADDING))
1297 .gap(px(12.))
1298 .items_center();
1299 let title_group = h_flex()
1300 .flex_1()
1301 .flex_basis(px(0.))
1302 .min_w_0()
1343 .px(px(20.))
1303 1344 .gap(px(12.))
1304 1345 .items_center()
1305 1346 .child(icon(IconName::Phone, 18., theme::accent_text()))
@@ -1321,59 +1362,40 @@ pub fn render_call_view(
1321 1362 .children(health_indicator(model))
1322 1363 .children(recording_chip(model))
1323 1364 .children(lock_chip(model))
1324 .children(room_chip(model));
1325 let end_group = h_flex()
1326 .flex_1()
1327 .flex_basis(px(0.))
1328 .min_w_0()
1329 .justify_end()
1330 .gap(px(GROUP_GAP))
1331 .items_center()
1332 .children(return_button(app, model))
1333 .child(leave_group(app, model));
1365 .children(room_chip(model))
1366 .child(div().flex_1())
1367 .children(return_button(app, model));
1334 1368
1335 1369 let hold = hold_panel(app, model);
1336 1370 let share_stage = share_stage_element(app, state, call);
1337 1371 let region = stage_region(app, state, call, now, hold, share_stage);
1338 1372
1339 1373 let folded = folded_controls(state, call, fullscreen);
1340 let panels_and_reactions = h_flex()
1341 .gap(px(TOOL_GAP))
1342 .items_center()
1343 .when(
1344 model.has_reaction_controls() && !folded.folds(Foldable::Reactions),
1345 |row| row.child(reactions_button(app, model)),
1346 )
1347 .when(
1348 call.chat_thread().is_some() && !folded.folds(Foldable::Chat),
1349 |row| row.child(chat_button(app, call.chat_open, state.call_chat_unread())),
1350 )
1351 .when(
1352 model.kind != CallKind::Test && !folded.folds(Foldable::People),
1353 |row| row.child(people_button(app, call.people_open, model.raised_hands())),
1354 );
1355 let stage_and_more = h_flex()
1356 .gap(px(TOOL_GAP))
1357 .items_center()
1358 .when(shows_pop_out(call), |row| row.child(pop_out_tool(app)))
1359 .when(!folded.folds(Foldable::View), |row| {
1360 row.child(view_button(app, model, fullscreen))
1361 })
1362 .children(more_button(app, model, &folded));
1363 let devices = h_flex()
1364 .gap(px(TOOL_GAP))
1374 let controls = h_flex()
1375 .w_full()
1376 .flex_none()
1377 .py(px(16.))
1378 .px(px(CONTROLS_PADDING))
1379 .gap(px(CONTROL_GAP))
1365 1380 .items_center()
1381 .justify_center()
1366 1382 .child(
1367 1383 h_flex()
1368 .debug_selector(|| "shell/islands/main/call-header/controls/mic".into())
1384 .debug_selector(|| "shell/islands/main/call-controls/mic".into())
1385 .h(px(CONTROL_SIZE))
1369 1386 .items_center()
1370 .child(toolbar_mic(app, model))
1387 .rounded_full()
1388 .bg(theme::surface_raised())
1389 .child(mute_button(app, model, "call-mute", CONTROL_SIZE))
1371 1390 .child(mic_menu_button(app, model, state.call_mic)),
1372 1391 )
1373 1392 .child(
1374 1393 h_flex()
1394 .h(px(CONTROL_SIZE))
1375 1395 .items_center()
1376 .child(toolbar_camera(app, model))
1396 .rounded_full()
1397 .bg(theme::surface_raised())
1398 .child(camera_button(app, model))
1377 1399 .children(camera_menu_button(app, model, CameraMenu::of(state))),
1378 1400 )
1379 1401 .child(share_button(
@@ -1381,18 +1403,34 @@ pub fn render_call_view(
1381 1403 model,
1382 1404 ShareOptions::of(state),
1383 1405 call.share_menu_open,
1384 ));
1385 let controls = h_flex()
1386 .debug_selector(|| "shell/islands/main/call-header/controls".into())
1387 .flex_none()
1388 .gap(px(GROUP_GAP))
1389 .items_center()
1390 .child(devices)
1391 .child(group_divider())
1392 .child(panels_and_reactions)
1393 .child(group_divider())
1394 .child(stage_and_more);
1395 let header = header.child(title_group).child(controls).child(end_group);
1406 ))
1407 .when(
1408 model.has_reaction_controls() && !folded.folds(Foldable::RaiseHand),
1409 |row| row.child(hand_button(app, model)),
1410 )
1411 .when(
1412 model.has_reaction_controls() && !folded.folds(Foldable::Reactions),
1413 |row| row.child(reactions_button(app, model)),
1414 )
1415 .when(!folded.folds(Foldable::View), |row| {
1416 row.child(view_button(app, model, fullscreen))
1417 })
1418 .children(more_button(app, model, &folded))
1419 .when(
1420 model.kind != CallKind::Test && !folded.folds(Foldable::People),
1421 |row| row.child(people_button(app, call.people_open, model.raised_hands())),
1422 )
1423 .when(
1424 call.chat_thread().is_some() && !folded.folds(Foldable::Chat),
1425 |row| row.child(chat_button(app, call.chat_open, state.call_chat_unread())),
1426 )
1427 .child(
1428 leave_button(app, model, "call-leave", false)
1429 .debug_selector(|| "shell/islands/main/call-controls/leave".into()),
1430 )
1431 .when(has_leave_menu(model), |row| {
1432 row.child(leave_menu(app, model))
1433 });
1396 1434
1397 1435 let top = v_flex()
1398 1436 .w_full()
@@ -1423,19 +1461,28 @@ pub fn render_call_view(
1423 1461 column.child(fullscreen_chrome("call-chrome-top", app, top))
1424 1462 })
1425 1463 .child(region)
1464 .when(chrome_visible, |column| {
1465 column.child(fullscreen_chrome("call-chrome-bottom", app, controls))
1466 })
1426 1467 } else {
1427 1468 base.rounded(px(10.))
1428 1469 .child(top.debug_selector(|| "shell/islands/main/call-header".into()))
1429 1470 .child(region)
1471 .child(controls.debug_selector(|| "shell/islands/main/call-controls".into()))
1430 1472 }
1431 1473 .children(captions_overlay(model, now))
1432 1474 .children(captions_hint_chip(model))
1433 1475 .children(push_to_talk_chip(call))
1434 1476 .children(state.transfer_picker.clone())
1435 1477 .children(options_dialog(app, call))
1436 .children(consent_overlay(app, model));
1478 .children(consent_overlay(app, model))
1479 .children(local_share_float(app, state));
1480 let share_in_chat = call
1481 .chat_open
1482 .then(|| local_share_window(app, state, CHAT_PANEL_WIDTH))
1483 .flatten();
1437 1484 let panels: Vec<AnyElement> = chat
1438 .map(|chat| chat_panel(app, chat))
1485 .map(|chat| chat_panel(app, share_in_chat, chat))
1439 1486 .into_iter()
1440 1487 .chain(
1441 1488 call.transcript_open
@@ -1469,17 +1516,15 @@ fn side_panels(panels: Vec<AnyElement>, island_width: f32) -> Vec<AnyElement> {
1469 1516 if island_width - panels_width >= OVERLAY_BELOW {
1470 1517 return panels;
1471 1518 }
1472 vec![
1473 h_flex()
1474 .absolute()
1475 .top(px(HEADER_HEIGHT))
1476 .right_0()
1477 .bottom_0()
1478 .gap(px(ISLAND_GAP))
1479 .w(px(panels_width.min(island_width)))
1480 .children(panels)
1481 .into_any_element(),
1482 ]
1519 vec![h_flex()
1520 .absolute()
1521 .top_0()
1522 .right_0()
1523 .bottom(px(CONTROLS_HEIGHT))
1524 .gap(px(ISLAND_GAP))
1525 .w(px(panels_width.min(island_width)))
1526 .children(panels)
1527 .into_any_element()]
1483 1528 }
1484 1529
1485 1530 fn fullscreen_chrome(id: &'static str, app: &Entity<AppState>, content: Div) -> Stateful<Div> {
@@ -1494,19 +1539,146 @@ fn fullscreen_chrome(id: &'static str, app: &Entity<AppState>, content: Div) ->
1494 1539 .child(content)
1495 1540 }
1496 1541
1497 fn chat_panel(app: &Entity<AppState>, chat: AnyView) -> AnyElement {
1542 fn chat_panel(app: &Entity<AppState>, share: Option<AnyElement>, chat: AnyView) -> AnyElement {
1498 1543 let app = app.clone();
1544 let body = v_flex()
1545 .w_full()
1546 .flex_1()
1547 .min_h_0()
1548 .children(share)
1549 .child(div().flex_1().min_h_0().overflow_hidden().child(chat));
1499 1550 side_panel(
1500 1551 "call-chat-panel",
1501 1552 "Chat",
1502 1553 "Close the chat",
1503 1554 move |cx| app.update(cx, |state, cx| state.toggle_call_chat(cx)),
1504 chat,
1555 body,
1505 1556 )
1506 1557 .debug_selector(|| CHAT_PANEL_TAG.into())
1507 1558 .into_any_element()
1508 1559 }
1509 1560
1561 const SHARE_WINDOW_INSET: f32 = 12.;
1562 const SHARE_WINDOW_RATIO: f32 = 9. / 16.;
1563 const SHARE_FLOAT_WIDTH: f32 = 320.;
1564
1565 /// The live local share, pinned in the meeting chat or floating on the call
1566 /// when the chat is closed.
1567 fn local_share_window(app: &Entity<AppState>, state: &AppState, width: f32) -> Option<AnyElement> {
1568 let call = state.call.as_ref()?;
1569 let label = call.model.local_share.clone()?;
1570 let image = call.pictures.live(&VideoKey::LocalScreen, Instant::now());
1571 Some(share_window(app, &label, image, width))
1572 }
1573
1574 fn local_share_float(app: &Entity<AppState>, state: &AppState) -> Option<AnyElement> {
1575 let call = state.call.as_ref()?;
1576 if call.chat_open {
1577 return None;
1578 }
1579 let window = local_share_window(app, state, SHARE_FLOAT_WIDTH)?;
1580 Some(
1581 div()
1582 .absolute()
1583 .right(px(16.))
1584 .bottom(px(CONTROLS_HEIGHT + 12.))
1585 .w(px(SHARE_FLOAT_WIDTH))
1586 .rounded(px(10.))
1587 .overflow_hidden()
1588 .bg(theme::surface())
1589 .shadow(theme::flyout_shadow())
1590 .child(window)
1591 .into_any_element(),
1592 )
1593 }
1594
1595 fn share_window(
1596 app: &Entity<AppState>,
1597 label: &str,
1598 image: Option<Arc<RenderImage>>,
1599 width: f32,
1600 ) -> AnyElement {
1601 let picture_width = (width - 2. * SHARE_WINDOW_INSET).max(0.);
1602 let picture_height = picture_width * SHARE_WINDOW_RATIO;
1603 let stop = app.clone();
1604 v_flex()
1605 .w_full()
1606 .flex_none()
1607 .p(px(SHARE_WINDOW_INSET))
1608 .child(
1609 div()
1610 .id("call-share-window")
1611 .relative()
1612 .w(px(picture_width))
1613 .h(px(picture_height))
1614 .rounded(px(8.))
1615 .overflow_hidden()
1616 .bg(hsla(0., 0., 0.04, 1.))
1617 .child(share_picture(image))
1618 .child(
1619 div()
1620 .absolute()
1621 .top(px(8.))
1622 .left(px(8.))
1623 .max_w(px(picture_width * 0.62))
1624 .h(px(22.))
1625 .px(px(8.))
1626 .flex()
1627 .items_center()
1628 .rounded_full()
1629 .bg(hsla(0., 0., 0., 0.6))
1630 .text_size(px(11.))
1631 .text_color(theme::white())
1632 .child(div().truncate().child(label.to_owned())),
1633 )
1634 .child(share_stop(stop)),
1635 )
1636 .into_any_element()
1637 }
1638
1639 fn share_picture(image: Option<Arc<RenderImage>>) -> AnyElement {
1640 let Some(image) = image else {
1641 return div()
1642 .size_full()
1643 .flex()
1644 .items_center()
1645 .justify_center()
1646 .px(px(12.))
1647 .text_size(px(12.))
1648 .text_color(theme::text_muted())
1649 .child(WAITING_TEXT)
1650 .into_any_element();
1651 };
1652 img(ImageSource::Render(image))
1653 .size_full()
1654 .object_fit(ObjectFit::Contain)
1655 .into_any_element()
1656 }
1657
1658 fn share_stop(app: Entity<AppState>) -> Stateful<Div> {
1659 div()
1660 .id("call-share-window-stop")
1661 .absolute()
1662 .top(px(8.))
1663 .right(px(8.))
1664 .h(px(22.))
1665 .px(px(8.))
1666 .flex()
1667 .items_center()
1668 .rounded_full()
1669 .bg(theme::red())
1670 .text_color(theme::white())
1671 .text_size(px(11.))
1672 .font_weight(FontWeight::SEMIBOLD)
1673 .cursor_pointer()
1674 .hover(|button| button.opacity(0.85))
1675 .child("Stop")
1676 .on_click(move |_, _, cx| {
1677 cx.stop_propagation();
1678 app.update(cx, |state, cx| state.stop_call_share(cx));
1679 })
1680 }
1681
1510 1682 pub fn side_panel(
1511 1683 panel_id: &'static str,
1512 1684 title: &'static str,
@@ -1558,14 +1730,25 @@ pub fn side_panel(
1558 1730
1559 1731 #[cfg(test)]
1560 1732 mod tests {
1561 use super::{TileSize, name_plate_metrics};
1733 use super::{name_plate_metrics, TileSize};
1562 1734
1563 1735 #[test]
1564 1736 fn small_strip_tiles_get_a_compact_name_plate() {
1565 let strip = name_plate_metrics(TileSize { width: 216., height: 121.5, avatar: 48. });
1566 assert_eq!((strip.text_size, strip.inset, strip.padding_y), (11., 4., 2.));
1737 let strip = name_plate_metrics(TileSize {
1738 width: 216.,
1739 height: 121.5,
1740 avatar: 48.,
1741 });
1742 assert_eq!(
1743 (strip.text_size, strip.inset, strip.padding_y),
1744 (11., 4., 2.)
1745 );
1567 1746 assert!(strip.max_width_share < 1.);
1568 let stage = name_plate_metrics(TileSize { width: 640., height: 360., avatar: 96. });
1747 let stage = name_plate_metrics(TileSize {
1748 width: 640.,
1749 height: 360.,
1750 avatar: 96.,
1751 });
1569 1752 assert_eq!((stage.text_size, stage.inset), (12., 8.));
1570 1753 }
1571 1754 }
@@ -16,32 +16,32 @@ use gpui_kit::prelude::FluentBuilder as _;
16use gpui_kit::*;
16use gpui_kit::*;
17
17
18use super::avatar::person_avatar;
18use super::avatar::person_avatar;
19use super::call_control_fold::{Foldable, FoldedControls, fixed_controls_width, folded_for_width, in_more_menu};
19use super::call_control_fold::{
20use super::call_toolbar::{
20 fixed_controls_width, folded_for_width, Foldable, FoldedControls, CONTROLS_PADDING, CONTROL_GAP,
21 GROUP_GAP, LEAVE_HEIGHT, group_divider, SPLIT_CHEVRON_WIDTH, TOOL_GAP, tool_face, tool_trigger, split_chevron,
22};
21};
23use super::call_extras::{
22use super::call_extras::{
24 CameraMenu, consent_overlay, consult_banner, hold_panel, recording_chip, return_button,
23 consent_overlay, consult_banner, hold_panel, recording_chip, return_button, room_chip,
25 room_chip, whiteboard_stage,
24 whiteboard_stage, CameraMenu,
26};
25};
27use super::call_health::{health_banner, health_indicator};
26use super::call_health::{health_banner, health_indicator};
28use super::call_layouts::stage_region;
27use super::call_layouts::stage_region;
29use crate::call::measured_stage;
30use super::call_organizer::{
28use super::call_organizer::{
31 camera_menu_button, captions_hint_chip, captions_overlay, lobby_banner,
29 camera_menu_button, captions_hint_chip, captions_overlay, chevron_button, lobby_banner,
32 more_button, pin_chip, spotlight_chip, with_tile_menu,
30 more_button, pin_chip, spotlight_chip, with_tile_menu,
33};
31};
34use super::call_people::{lock_banner, lock_chip, options_dialog, people_button, people_panel};
32use super::call_people::{lock_banner, lock_chip, options_dialog, people_button, people_panel};
35use super::call_stage::{POP_OUT_TOOLTIP, StageMode, popped_placeholder, render_stage};
33use super::call_stage::{popped_placeholder, render_stage, StageMode, WAITING_TEXT};
36use super::call_view_menu::view_button;
34use super::call_view_menu::view_button;
37use app_ui_kit::layout::ISLAND_GAP;
35use super::widgets::{corner_badge, count_badge, icon, Corner};
38use super::widgets::{Corner, corner_badge, count_badge, icon};
39use crate::app_state::AppState;
36use crate::app_state::AppState;
40use crate::call::REACTION_SHOWN;
37use crate::call::measured_stage;
38use crate::call::model::ShareMenuEntry;
41use crate::call::TileSize;
39use crate::call::TileSize;
40use crate::call::REACTION_SHOWN;
42use crate::call::{ActiveCall, CallKind, CallModel, Tile, TileState};
41use crate::call::{ActiveCall, CallKind, CallModel, Tile, TileState};
43use crate::rows::reaction_glyph as chat_reaction_glyph;
42use crate::rows::reaction_glyph as chat_reaction_glyph;
44use crate::theme;
43use crate::theme;
44use app_ui_kit::layout::ISLAND_GAP;
45
45
46const HEADER_HEIGHT: f32 = 60.;
46const HEADER_HEIGHT: f32 = 60.;
47const RING_WIDTH: f32 = 3.;
47const RING_WIDTH: f32 = 3.;
@@ -64,7 +64,6 @@ pub const NO_CAMERA_HINT: &str = "No camera found";
64pub const NO_SHARE_HINT: &str = "Sharing starts once the call is connected";
64pub const NO_SHARE_HINT: &str = "Sharing starts once the call is connected";
65pub const NO_WINDOWS_HINT: &str = "No windows found";
65pub const NO_WINDOWS_HINT: &str = "No windows found";
66pub(super) const BANNER_HEIGHT: f32 = 40.;
66pub(super) const BANNER_HEIGHT: f32 = 40.;
67const MAX_WINDOW_ITEMS: usize = 12;
68pub const SHARE_THUMBNAIL_TAG: &str = "call/share-menu/thumbnail";
67pub const SHARE_THUMBNAIL_TAG: &str = "call/share-menu/thumbnail";
69const SCREEN_THUMBNAIL: (f32, f32) = (128., 72.);
68const SCREEN_THUMBNAIL: (f32, f32) = (128., 72.);
70const WINDOW_THUMBNAIL: (f32, f32) = (96., 54.);
69const WINDOW_THUMBNAIL: (f32, f32) = (96., 54.);
@@ -73,8 +72,7 @@ const THUMBNAIL_ICON: f32 = 22.;
73pub const LOBBY_TEXT: &str = "Waiting in the lobby...";
72pub const LOBBY_TEXT: &str = "Waiting in the lobby...";
74pub(super) const CHAT_PANEL_WIDTH: f32 = 320.;
73pub(super) const CHAT_PANEL_WIDTH: f32 = 320.;
75pub(super) const OVERLAY_BELOW: f32 = 720.;
74pub(super) const OVERLAY_BELOW: f32 = 720.;
76const HEADER_END_PADDING: f32 = 8.;
75const CONTROLS_HEIGHT: f32 = 2. * 16. + CONTROL_SIZE;
77const LEAVE_RADIUS: f32 = 6.;
78const CHAT_HEADER_HEIGHT: f32 = 48.;
76const CHAT_HEADER_HEIGHT: f32 = 48.;
79const REACTION_RISE: f32 = 24.;
77const REACTION_RISE: f32 = 24.;
80const REACTION_FADE_FROM: f32 = 0.75;
78const REACTION_FADE_FROM: f32 = 0.75;
@@ -90,8 +88,13 @@ const PUSH_TO_TALK_TOP: f32 = 12.;
90
88
91pub fn reaction_glyph(reaction: &Reaction) -> String {
89pub fn reaction_glyph(reaction: &Reaction) -> String {
92 match reaction {
90 match reaction {
91 Reaction::Like => "\u{1F44D}".to_owned(),
92 // Keep VS16 so the heart stays emoji-style, not a text outline.
93 Reaction::Heart => "\u{2764}\u{FE0F}".to_owned(),
93 Reaction::Applause => "\u{1F44F}".to_owned(),
94 Reaction::Applause => "\u{1F44F}".to_owned(),
94 other => chat_reaction_glyph(other.name()),
95 Reaction::Laugh => "\u{1F606}".to_owned(),
96 Reaction::Surprised => "\u{1F62E}".to_owned(),
97 Reaction::Other(name) => chat_reaction_glyph(name),
95 }
98 }
96}
99}
97
100
@@ -143,6 +146,7 @@ fn reaction_chip(reaction: Reaction, serial: u64) -> AnyElement {
143 .rounded_full()
146 .rounded_full()
144 .bg(theme::popup())
147 .bg(theme::popup())
145 .text_size(px(if emoji { 20. } else { 13. }))
148 .text_size(px(if emoji { 20. } else { 13. }))
149 .when(emoji, |chip| chip.font_family(theme::EMOJI_FONT_FAMILY))
146 .child(glyph)
150 .child(glyph)
147 .with_animation(
151 .with_animation(
148 ("call-reaction", serial as usize),
152 ("call-reaction", serial as usize),
@@ -251,9 +255,23 @@ struct NamePlate {
251
255
252fn name_plate_metrics(size: TileSize) -> NamePlate {
256fn name_plate_metrics(size: TileSize) -> NamePlate {
253 if size.height < COMPACT_PLATE_BELOW {
257 if size.height < COMPACT_PLATE_BELOW {
254 NamePlate { inset: 4., padding_x: 6., padding_y: 2., radius: 4., text_size: 11., max_width_share: 0.6 }
258 NamePlate {
259 inset: 4.,
260 padding_x: 6.,
261 padding_y: 2.,
262 radius: 4.,
263 text_size: 11.,
264 max_width_share: 0.6,
265 }
255 } else {
266 } else {
256 NamePlate { inset: 8., padding_x: 8., padding_y: 4., radius: 6., text_size: 12., max_width_share: 1. }
267 NamePlate {
268 inset: 8.,
269 padding_x: 8.,
270 padding_y: 4.,
271 radius: 6.,
272 text_size: 12.,
273 max_width_share: 1.,
274 }
257 }
275 }
258}
276}
259
277
@@ -263,7 +281,9 @@ fn name_plate(size: TileSize, name: &str) -> Div {
263 .absolute()
281 .absolute()
264 .left(px(plate.inset))
282 .left(px(plate.inset))
265 .bottom(px(plate.inset))
283 .bottom(px(plate.inset))
266 .max_w(px(((size.width - 3. * plate.inset) * plate.max_width_share).max(0.)))
284 .max_w(px(((size.width - 3. * plate.inset)
285 * plate.max_width_share)
286 .max(0.)))
267 .truncate()
287 .truncate()
268 .px(px(plate.padding_x))
288 .px(px(plate.padding_x))
269 .py(px(plate.padding_y))
289 .py(px(plate.padding_y))
@@ -385,19 +405,7 @@ pub fn mute_button(
385 } else {
405 } else {
386 (IconName::Mic, theme::surface_raised(), theme::text())
406 (IconName::Mic, theme::surface_raised(), theme::text())
387 };
407 };
388 mic_action(round_control(id, glyph, background, foreground).size(px(size)), app, model)
408 let button = round_control(id, glyph, background, foreground).size(px(size));
389}
390
391fn toolbar_mic(app: &Entity<AppState>, model: &CallModel) -> Stateful<Div> {
392 let glyph = if model.muted {
393 IconName::MicOff
394 } else {
395 IconName::Mic
396 };
397 mic_action(tool_face("call-mute", glyph, "Mic", false), app, model)
398}
399
400fn mic_action(button: Stateful<Div>, app: &Entity<AppState>, model: &CallModel) -> Stateful<Div> {
401 if !model.can_unmute() {
409 if !model.can_unmute() {
402 let hint = if model.audio_off {
410 let hint = if model.audio_off {
403 AUDIO_OFF_HINT
411 AUDIO_OFF_HINT
@@ -430,8 +438,8 @@ pub fn leave_button(
430 let app = app.clone();
438 let app = app.clone();
431 h_flex()
439 h_flex()
432 .id(id)
440 .id(id)
433 .h(px(if compact { 28. } else { LEAVE_HEIGHT }))
441 .h(px(if compact { 28. } else { CONTROL_SIZE }))
434 .px(px(if compact { 10. } else { 14. }))
442 .px(px(if compact { 10. } else { 20. }))
435 .gap(px(8.))
443 .gap(px(8.))
436 .flex_none()
444 .flex_none()
437 .items_center()
445 .items_center()
@@ -439,13 +447,13 @@ pub fn leave_button(
439 .rounded_full()
447 .rounded_full()
440 .bg(theme::red())
448 .bg(theme::red())
441 .text_color(theme::white())
449 .text_color(theme::white())
442 .text_size(px(if compact { 12. } else { 13. }))
450 .text_size(px(if compact { 12. } else { 14. }))
443 .font_weight(FontWeight::SEMIBOLD)
451 .font_weight(FontWeight::SEMIBOLD)
444 .cursor_pointer()
452 .cursor_pointer()
445 .hover(|button| button.opacity(0.85))
453 .hover(|button| button.opacity(0.85))
446 .child(icon(
454 .child(icon(
447 IconName::PhoneOff,
455 IconName::PhoneOff,
448 if compact { 14. } else { 16. },
456 if compact { 14. } else { 18. },
449 theme::white(),
457 theme::white(),
450 ))
458 ))
451 .child(label)
459 .child(label)
@@ -455,7 +463,11 @@ pub fn leave_button(
455 })
463 })
456}
464}
457
465
458fn share_stage_element(app: &Entity<AppState>, state: &AppState, call: &ActiveCall) -> Option<AnyElement> {
466fn share_stage_element(
467 app: &Entity<AppState>,
468 state: &AppState,
469 call: &ActiveCall,
470) -> Option<AnyElement> {
459 if call.share_stage.popped && call.model.screen_sharer.is_some() {
471 if call.share_stage.popped && call.model.screen_sharer.is_some() {
460 return Some(popped_placeholder(app));
472 return Some(popped_placeholder(app));
461 }
473 }
@@ -468,19 +480,7 @@ pub(super) fn camera_button(app: &Entity<AppState>, model: &CallModel) -> Statef
468 } else {
480 } else {
469 (IconName::VideoOff, theme::surface_raised(), theme::text())
481 (IconName::VideoOff, theme::surface_raised(), theme::text())
470 };
482 };
471 camera_action(round_control("call-camera", glyph, background, foreground), app, model)
483 let button = round_control("call-camera", glyph, background, foreground);
472}
473
474fn toolbar_camera(app: &Entity<AppState>, model: &CallModel) -> Stateful<Div> {
475 let glyph = if model.camera_on {
476 IconName::Video
477 } else {
478 IconName::VideoOff
479 };
480 camera_action(tool_face("call-camera", glyph, "Camera", false), app, model)
481}
482
483fn camera_action(button: Stateful<Div>, app: &Entity<AppState>, model: &CallModel) -> Stateful<Div> {
484 if !model.can_use_camera() {
484 if !model.can_use_camera() {
485 return button
485 return button
486 .opacity(DISABLED_OPACITY)
486 .opacity(DISABLED_OPACITY)
@@ -550,7 +550,9 @@ fn standout_switch_item(app: &Entity<AppState>, standout: bool, camera_on: bool)
550 })
550 })
551 })
551 })
552 .disabled(!camera_on)
552 .disabled(!camera_on)
553 .on_click(move |_, _, cx| app.update(cx, |state, cx| state.set_call_share_standout(!standout, cx)))
553 .on_click(move |_, _, cx| {
554 app.update(cx, |state, cx| state.set_call_share_standout(!standout, cx))
555 })
554}
556}
555
557
556fn music_mode_item(app: &Entity<AppState>, mic: MicSettings) -> PopupMenuItem {
558fn music_mode_item(app: &Entity<AppState>, mic: MicSettings) -> PopupMenuItem {
@@ -624,6 +626,72 @@ fn share_items(
624 model: &CallModel,
626 model: &CallModel,
625 options: ShareOptions,
627 options: ShareOptions,
626) -> PopupMenu {
628) -> PopupMenu {
629<<<<<<< ours
630 let single_screen = model.screens().len() == 1;
631 let mut screen_index = 0usize;
632 let mut separated = false;
633 let mut popup = popup.min_w(px(SHARE_MENU_WIDTH));
634 for entry in model.share_menu_entries() {
635 popup = match entry {
636 ShareMenuEntry::Sound => popup.item(sound_switch_item(app, options.sound)),
637 ShareMenuEntry::Motion => popup.item(motion_switch_item(app, options.motion)),
638 ShareMenuEntry::Standout => {
639 popup.item(standout_switch_item(app, options.standout, model.camera_on))
640 }
641 ShareMenuEntry::Portal(kind) => {
642 if !separated {
643 popup = popup.separator();
644 separated = true;
645 }
646 let label = match kind {
647 ShareKind::Screen => "Share entire screen",
648 ShareKind::Window => "Share a window",
649 };
650 let app = app.clone();
651 popup.item(PopupMenuItem::new(label).on_click(move |_, _, cx| {
652 app.update(cx, |state, cx| state.start_portal_share(kind, cx))
653 }))
654 }
655 ShareMenuEntry::Source(source) => {
656 if !separated {
657 popup = popup.separator();
658 separated = true;
659 }
660 let (label, thumbnail, icon, size) = if source.kind == ShareKind::Screen {
661 screen_index += 1;
662 let label = if single_screen {
663 "Share entire screen".to_owned()
664 } else {
665 format!("Share screen {screen_index}")
666 };
667 (
668 label,
669 model.share_thumbnail(&source),
670 IconName::Monitor,
671 SCREEN_THUMBNAIL,
672 )
673 } else {
674 (
675 source.label(),
676 model.share_thumbnail(&source),
677 IconName::AppWindow,
678 WINDOW_THUMBNAIL,
679 )
680 };
681 let app = app.clone();
682 popup.item(share_source_item(label, thumbnail, icon, size).on_click(
683 move |_, _, cx| {
684 app.update(cx, |state, cx| state.start_call_share(source.clone(), cx))
685 },
686 ))
687 }
688 ShareMenuEntry::WindowHeader => popup
689 .separator()
690 .item(PopupMenuItem::label("Share a window...")),
691 ShareMenuEntry::NoWindows => {
692 popup.item(PopupMenuItem::new(NO_WINDOWS_HINT).disabled(true))
693 }
694=======
627 let mut popup = popup
695 let mut popup = popup
628 .min_w(px(SHARE_MENU_WIDTH))
696 .min_w(px(SHARE_MENU_WIDTH))
629 .item(sound_switch_item(app, options.sound))
697 .item(sound_switch_item(app, options.sound))
@@ -654,33 +722,8 @@ fn share_items(
654 "Share entire screen".to_owned()
722 "Share entire screen".to_owned()
655 } else {
723 } else {
656 format!("Share screen {}", index + 1)
724 format!("Share screen {}", index + 1)
725>>>>>>> theirs
657 };
726 };
658 let thumbnail = model.share_thumbnail(source);
659 let source = source.clone();
660 let app = app.clone();
661 popup = popup.item(
662 share_source_item(label, thumbnail, IconName::Monitor, SCREEN_THUMBNAIL).on_click(
663 move |_, _, cx| app.update(cx, |state, cx| state.start_call_share(source.clone(), cx)),
664 ),
665 );
666 }
667 popup = popup
668 .separator()
669 .item(PopupMenuItem::label("Share a window..."));
670 let windows = model.windows();
671 if windows.is_empty() {
672 return popup.item(PopupMenuItem::new(NO_WINDOWS_HINT).disabled(true));
673 }
674 for source in windows.into_iter().take(MAX_WINDOW_ITEMS) {
675 let label = source.label();
676 let thumbnail = model.share_thumbnail(source);
677 let source = source.clone();
678 let app = app.clone();
679 popup = popup.item(
680 share_source_item(label, thumbnail, IconName::AppWindow, WINDOW_THUMBNAIL).on_click(
681 move |_, _, cx| app.update(cx, |state, cx| state.start_call_share(source.clone(), cx)),
682 ),
683 );
684 }
727 }
685 popup
728 popup
686}
729}
@@ -733,7 +776,12 @@ fn share_button(
733) -> AnyElement {
776) -> AnyElement {
734 if model.local_share.is_some() {
777 if model.local_share.is_some() {
735 let app = app.clone();
778 let app = app.clone();
736 return tool_face("call-share-stop", IconName::ScreenShareOff, "Stop", true)
779 return round_control(
780 "call-share-stop",
781 IconName::ScreenShareOff,
782 theme::accent(),
783 theme::on_accent(),
784 )
737 .tooltip(|window, cx| Tooltip::new("Stop sharing").build(window, cx))
785 .tooltip(|window, cx| Tooltip::new("Stop sharing").build(window, cx))
738 .on_click(move |_, _, cx| {
786 .on_click(move |_, _, cx| {
739 cx.stop_propagation();
787 cx.stop_propagation();
@@ -741,7 +789,12 @@ fn share_button(
741 })
789 })
742 .into_any_element();
790 .into_any_element();
743 }
791 }
744 let face = tool_face("call-share-face", IconName::ScreenShare, "Share", false);
792 let face = round_control(
793 "call-share-face",
794 IconName::ScreenShare,
795 theme::surface_raised(),
796 theme::text(),
797 );
745 if !model.can_share() {
798 if !model.can_share() {
746 return face
799 return face
747 .opacity(DISABLED_OPACITY)
800 .opacity(DISABLED_OPACITY)
@@ -752,8 +805,13 @@ fn share_button(
752 let app = app.clone();
805 let app = app.clone();
753 let open_app = app.clone();
806 let open_app = app.clone();
754 let model = model.clone();
807 let model = model.clone();
755 tool_trigger("call-share", face)
808 Button::new("call-share")
756 .dropdown_menu_with_anchor(Anchor::TopRight, move |popup, _, _| {
809 .ghost()
810 .p_0()
811 .size(px(CONTROL_SIZE))
812 .rounded_full()
813 .child(face)
814 .dropdown_menu_with_anchor(Anchor::BottomLeft, move |popup, _, _| {
757 share_items(popup, &app, &model, options)
815 share_items(popup, &app, &model, options)
758 })
816 })
759 .open(menu_open)
817 .open(menu_open)
@@ -826,7 +884,12 @@ fn sharing_banner(app: &Entity<AppState>, model: &CallModel, sound: bool) -> Opt
826
884
827fn chat_button(app: &Entity<AppState>, open: bool, unread: u32) -> Stateful<Div> {
885fn chat_button(app: &Entity<AppState>, open: bool, unread: u32) -> Stateful<Div> {
828 let app = app.clone();
886 let app = app.clone();
829 tool_face("call-chat", IconName::MessageCircle, "Chat", open)
887 let (background, foreground) = if open {
888 (theme::accent(), theme::on_accent())
889 } else {
890 (theme::surface_raised(), theme::text())
891 };
892 round_control("call-chat", IconName::MessageCircle, background, foreground)
830 .relative()
893 .relative()
831 .tooltip(move |window, cx| {
894 .tooltip(move |window, cx| {
832 Tooltip::new(if open {
895 Tooltip::new(if open {
@@ -842,9 +905,41 @@ fn chat_button(app: &Entity<AppState>, open: bool, unread: u32) -> Stateful<Div>
842 .on_click(move |_, _, cx| app.update(cx, |state, cx| state.toggle_call_chat(cx)))
905 .on_click(move |_, _, cx| app.update(cx, |state, cx| state.toggle_call_chat(cx)))
843}
906}
844
907
845fn reactions_button(app: &Entity<AppState>, model: &CallModel) -> AnyElement {
908fn hand_button(app: &Entity<AppState>, model: &CallModel) -> Stateful<Div> {
846 let raised = model.own_hand.is_some();
909 let raised = model.own_hand.is_some();
847 let face = tool_face("call-reactions-face", IconName::FaceSlightlySmiling, "React", raised);
910 let background = if raised {
911 theme::accent()
912 } else {
913 theme::surface_raised()
914 };
915 let foreground = if raised {
916 theme::on_accent()
917 } else {
918 theme::text()
919 };
920 let button = control_shell("call-hand", background).child(icon(
921 IconName::Hand,
922 CONTROL_ICON,
923 foreground,
924 ));
925 let tooltip = if raised { "Lower hand" } else { "Raise hand" };
926 let button = button.tooltip(move |window, cx| Tooltip::new(tooltip).build(window, cx));
927 if !model.can_react() {
928 return button.opacity(DISABLED_OPACITY).cursor_default();
929 }
930 let app = app.clone();
931 button.on_click(move |_, _, cx| {
932 cx.stop_propagation();
933 app.update(cx, |state, cx| state.toggle_call_hand(cx));
934 })
935}
936
937fn reactions_button(app: &Entity<AppState>, model: &CallModel) -> AnyElement {
938 let face = control_shell("call-reactions-face", theme::surface_raised()).child(icon(
939 IconName::FaceSlightlySmiling,
940 CONTROL_ICON,
941 theme::text(),
942 ));
848 if !model.can_react() {
943 if !model.can_react() {
849 return face
944 return face
850 .opacity(DISABLED_OPACITY)
945 .opacity(DISABLED_OPACITY)
@@ -853,14 +948,19 @@ fn reactions_button(app: &Entity<AppState>, model: &CallModel) -> AnyElement {
853 }
948 }
854 let app = app.clone();
949 let app = app.clone();
855 Popover::new("call-reactions-popover")
950 Popover::new("call-reactions-popover")
856 .anchor(Anchor::TopRight)
951 .anchor(Anchor::BottomLeft)
857 .offset(px(6.))
952 .offset(px(10.))
858 .trigger(tool_trigger("call-reactions", face))
953 .trigger(
954 Button::new("call-reactions")
955 .ghost()
956 .p_0()
957 .size(px(CONTROL_SIZE))
958 .rounded_full()
959 .child(face),
960 )
859 .content(move |_, _, cx| {
961 .content(move |_, _, cx| {
860 let popover = cx.entity().downgrade();
962 let popover = cx.entity().downgrade();
861 let hand_app = app.clone();
963 h_flex()
862 let hand_popover = popover.clone();
863 let reactions = h_flex()
864 .id("call-reactions-row")
964 .id("call-reactions-row")
865 .gap(px(4.))
965 .gap(px(4.))
866 .children(Reaction::ALL.into_iter().map(|reaction| {
966 .children(Reaction::ALL.into_iter().map(|reaction| {
@@ -874,68 +974,23 @@ fn reactions_button(app: &Entity<AppState>, model: &CallModel) -> AnyElement {
874 .justify_center()
974 .justify_center()
875 .rounded(px(8.))
975 .rounded(px(8.))
876 .text_size(px(24.))
976 .text_size(px(24.))
977 .font_family(theme::EMOJI_FONT_FAMILY)
877 .cursor_pointer()
978 .cursor_pointer()
878 .hover(|cell| cell.bg(theme::border_strong()))
979 .hover(|cell| cell.bg(theme::border_strong()))
879 .child(reaction_glyph(&reaction))
980 .child(reaction_glyph(&reaction))
880 .on_click(move |_, window, cx| {
981 .on_click(move |_, window, cx| {
881 app.update(cx, |state, cx| state.send_call_reaction(reaction.clone(), cx));
982 app.update(cx, |state, cx| {
983 state.send_call_reaction(reaction.clone(), cx)
984 });
882 popover
985 popover
883 .update(cx, |state, cx| state.dismiss(window, cx))
986 .update(cx, |state, cx| state.dismiss(window, cx))
884 .ok();
987 .ok();
885 })
988 })
886 }));
989 }))
887 v_flex()
888 .gap(px(6.))
889 .child(reactions)
890 .child(
891 h_flex()
892 .id("call-hand")
893 .h(px(36.))
894 .px(px(10.))
895 .gap(px(8.))
896 .items_center()
897 .rounded(px(8.))
898 .cursor_pointer()
899 .when(raised, |row| row.bg(theme::accent_soft()))
900 .hover(|row| row.bg(theme::border_strong()))
901 .child(icon(IconName::Hand, 18., if raised { theme::accent_text() } else { theme::text() }))
902 .child(div().text_size(px(13.)).child(if raised { "Lower hand" } else { "Raise hand" }))
903 .on_click(move |_, window, cx| {
904 hand_app.update(cx, |state, cx| state.toggle_call_hand(cx));
905 hand_popover
906 .update(cx, |state, cx| state.dismiss(window, cx))
907 .ok();
908 }),
909 )
910 })
990 })
911 .into_any_element()
991 .into_any_element()
912}
992}
913
993
914fn pop_out_tool(app: &Entity<AppState>) -> Stateful<Div> {
915 let app = app.clone();
916 tool_face("call-pop-out", IconName::ExternalLink, POP_OUT_TOOLTIP, false)
917 .on_click(move |_, _, cx| app.update(cx, |state, cx| state.pop_out_stage(cx)))
918}
919
920fn shows_pop_out(call: &ActiveCall) -> bool {
921 call.model.screen_sharer.is_some() && !call.share_stage.popped
922}
923
924fn leave_group(app: &Entity<AppState>, model: &CallModel) -> AnyElement {
925 let leave = leave_button(app, model, "call-leave", false)
926 .rounded(px(LEAVE_RADIUS))
927 .debug_selector(|| "shell/islands/main/call-header/leave".into());
928 if !has_leave_menu(model) {
929 return leave.into_any_element();
930 }
931 h_flex()
932 .flex_none()
933 .gap(px(1.))
934 .child(leave.rounded_r(px(0.)))
935 .child(leave_menu(app, model))
936 .into_any_element()
937}
938
939fn has_leave_menu(model: &CallModel) -> bool {
994fn has_leave_menu(model: &CallModel) -> bool {
940 model.kind == CallKind::Meeting
995 model.kind == CallKind::Meeting
941 && (model.can_end_meeting || (model.can_lower_hands() && model.any_hand_raised()))
996 && (model.can_end_meeting || (model.can_lower_hands() && model.any_hand_raised()))
@@ -949,23 +1004,15 @@ fn leave_menu(app: &Entity<AppState>, model: &CallModel) -> impl IntoElement {
949 Button::new("call-leave-menu")
1004 Button::new("call-leave-menu")
950 .ghost()
1005 .ghost()
951 .p_0()
1006 .p_0()
952 .w(px(SPLIT_CHEVRON_WIDTH + 4.))
1007 .size(px(CONTROL_SIZE))
953 .h(px(LEAVE_HEIGHT))
1008 .rounded_full()
954 .rounded_r(px(LEAVE_RADIUS))
1009 .child(round_control(
955 .child(
1010 "call-leave-menu-face",
956 div()
1011 IconName::ChevronUp,
957 .id("call-leave-menu-face")
1012 theme::surface_raised(),
958 .size_full()
1013 theme::text(),
959 .flex()
1014 ))
960 .items_center()
1015 .dropdown_menu_with_anchor(Anchor::BottomRight, move |popup, _, _| {
961 .justify_center()
962 .rounded_r(px(LEAVE_RADIUS))
963 .bg(theme::red())
964 .cursor_pointer()
965 .hover(|face| face.opacity(0.85))
966 .child(icon(IconName::ChevronDown, 12., theme::white())),
967 )
968 .dropdown_menu_with_anchor(Anchor::TopRight, move |popup, _, _| {
969 let end_app = end_app.clone();
1016 let end_app = end_app.clone();
970 let lower_app = lower_app.clone();
1017 let lower_app = lower_app.clone();
971 let popup = popup.min_w(px(MENU_WIDTH));
1018 let popup = popup.min_w(px(MENU_WIDTH));
@@ -1074,11 +1121,15 @@ fn devices_menu(
1074 popup
1121 popup
1075}
1122}
1076
1123
1077fn mic_menu_button(app: &Entity<AppState>, model: &CallModel, mic: MicSettings) -> impl IntoElement {
1124fn mic_menu_button(
1125 app: &Entity<AppState>,
1126 model: &CallModel,
1127 mic: MicSettings,
1128) -> impl IntoElement {
1078 let app = app.clone();
1129 let app = app.clone();
1079 let model = model.clone();
1130 let model = model.clone();
1080 split_chevron("call-mic-menu", "call-mic-menu-face")
1131 chevron_button("call-mic-menu", "call-mic-menu-face")
1081 .dropdown_menu_with_anchor(Anchor::TopRight, move |popup, _, _| {
1132 .dropdown_menu_with_anchor(Anchor::BottomLeft, move |popup, _, _| {
1082 devices_menu(popup, &app, &model, mic)
1133 devices_menu(popup, &app, &model, mic)
1083 })
1134 })
1084}
1135}
@@ -1197,7 +1248,9 @@ pub(super) fn plain_own_tile(
1197 let extras = TileExtras {
1248 let extras = TileExtras {
1198 hand: model.own_hand.map(|rank| model.hand_position(rank)),
1249 hand: model.own_hand.map(|rank| model.hand_position(rank)),
1199 own: true,
1250 own: true,
1200 reaction: model.own_chip(now).map(|chip| (chip.reaction.clone(), chip.serial)),
1251 reaction: model
1252 .own_chip(now)
1253 .map(|chip| (chip.reaction.clone(), chip.serial)),
1201 spotlight: model.own_spotlight.is_some(),
1254 spotlight: model.own_spotlight.is_some(),
1202 pinned: model.is_pinned(own_mri),
1255 pinned: model.is_pinned(own_mri),
1203 fitted: false,
1256 fitted: false,
@@ -1252,9 +1305,9 @@ fn folded_controls(state: &AppState, call: &ActiveCall, fullscreen: bool) -> Fol
1252 if !has_more {
1305 if !has_more {
1253 return FoldedControls::default();
1306 return FoldedControls::default();
1254 }
1307 }
1255 let mut present = Vec::new();
1308 let mut present = vec![Foldable::View];
1256 if model.has_reaction_controls() {
1309 if model.has_reaction_controls() {
1257 present.push(Foldable::Reactions);
1310 present.extend([Foldable::Reactions, Foldable::RaiseHand]);
1258 }
1311 }
1259 if model.kind != CallKind::Test {
1312 if model.kind != CallKind::Test {
1260 present.push(Foldable::People);
1313 present.push(Foldable::People);
@@ -1262,14 +1315,9 @@ fn folded_controls(state: &AppState, call: &ActiveCall, fullscreen: bool) -> Fol
1262 if call.chat_thread().is_some() {
1315 if call.chat_thread().is_some() {
1263 present.push(Foldable::Chat);
1316 present.push(Foldable::Chat);
1264 }
1317 }
1265 let fixed = fixed_controls_width(
1318 let fixed = fixed_controls_width(model.can_use_camera(), has_more, has_leave_menu(model));
1266 model.can_use_camera(),
1267 has_more,
1268 has_leave_menu(model),
1269 shows_pop_out(call),
1270 );
1271 FoldedControls {
1319 FoldedControls {
1272 items: in_more_menu(folded_for_width(measured_stage(call).0, fixed, &present)),
1320 items: folded_for_width(measured_stage(call).0, fixed, &present),
1273 fullscreen,
1321 fullscreen,
1274 people_open: call.people_open,
1322 people_open: call.people_open,
1275 chat_open: call.chat_open,
1323 chat_open: call.chat_open,
@@ -1292,14 +1340,7 @@ pub fn render_call_view(
1292 .w_full()
1340 .w_full()
1293 .h(px(HEADER_HEIGHT))
1341 .h(px(HEADER_HEIGHT))
1294 .flex_none()
1342 .flex_none()
1295 .pl(px(20.))
1343 .px(px(20.))
1296 .pr(px(HEADER_END_PADDING))
1297 .gap(px(12.))
1298 .items_center();
1299 let title_group = h_flex()
1300 .flex_1()
1301 .flex_basis(px(0.))
1302 .min_w_0()
1303 .gap(px(12.))
1344 .gap(px(12.))
1304 .items_center()
1345 .items_center()
1305 .child(icon(IconName::Phone, 18., theme::accent_text()))
1346 .child(icon(IconName::Phone, 18., theme::accent_text()))
@@ -1321,59 +1362,40 @@ pub fn render_call_view(
1321 .children(health_indicator(model))
1362 .children(health_indicator(model))
1322 .children(recording_chip(model))
1363 .children(recording_chip(model))
1323 .children(lock_chip(model))
1364 .children(lock_chip(model))
1324 .children(room_chip(model));
1365 .children(room_chip(model))
1325 let end_group = h_flex()
1366 .child(div().flex_1())
1326 .flex_1()
1367 .children(return_button(app, model));
1327 .flex_basis(px(0.))
1328 .min_w_0()
1329 .justify_end()
1330 .gap(px(GROUP_GAP))
1331 .items_center()
1332 .children(return_button(app, model))
1333 .child(leave_group(app, model));
1334
1368
1335 let hold = hold_panel(app, model);
1369 let hold = hold_panel(app, model);
1336 let share_stage = share_stage_element(app, state, call);
1370 let share_stage = share_stage_element(app, state, call);
1337 let region = stage_region(app, state, call, now, hold, share_stage);
1371 let region = stage_region(app, state, call, now, hold, share_stage);
1338
1372
1339 let folded = folded_controls(state, call, fullscreen);
1373 let folded = folded_controls(state, call, fullscreen);
1340 let panels_and_reactions = h_flex()
1374 let controls = h_flex()
1341 .gap(px(TOOL_GAP))
1375 .w_full()
1342 .items_center()
1376 .flex_none()
1343 .when(
1377 .py(px(16.))
1344 model.has_reaction_controls() && !folded.folds(Foldable::Reactions),
1378 .px(px(CONTROLS_PADDING))
1345 |row| row.child(reactions_button(app, model)),
1379 .gap(px(CONTROL_GAP))
1346 )
1347 .when(
1348 call.chat_thread().is_some() && !folded.folds(Foldable::Chat),
1349 |row| row.child(chat_button(app, call.chat_open, state.call_chat_unread())),
1350 )
1351 .when(
1352 model.kind != CallKind::Test && !folded.folds(Foldable::People),
1353 |row| row.child(people_button(app, call.people_open, model.raised_hands())),
1354 );
1355 let stage_and_more = h_flex()
1356 .gap(px(TOOL_GAP))
1357 .items_center()
1358 .when(shows_pop_out(call), |row| row.child(pop_out_tool(app)))
1359 .when(!folded.folds(Foldable::View), |row| {
1360 row.child(view_button(app, model, fullscreen))
1361 })
1362 .children(more_button(app, model, &folded));
1363 let devices = h_flex()
1364 .gap(px(TOOL_GAP))
1365 .items_center()
1380 .items_center()
1381 .justify_center()
1366 .child(
1382 .child(
1367 h_flex()
1383 h_flex()
1368 .debug_selector(|| "shell/islands/main/call-header/controls/mic".into())
1384 .debug_selector(|| "shell/islands/main/call-controls/mic".into())
1385 .h(px(CONTROL_SIZE))
1369 .items_center()
1386 .items_center()
1370 .child(toolbar_mic(app, model))
1387 .rounded_full()
1388 .bg(theme::surface_raised())
1389 .child(mute_button(app, model, "call-mute", CONTROL_SIZE))
1371 .child(mic_menu_button(app, model, state.call_mic)),
1390 .child(mic_menu_button(app, model, state.call_mic)),
1372 )
1391 )
1373 .child(
1392 .child(
1374 h_flex()
1393 h_flex()
1394 .h(px(CONTROL_SIZE))
1375 .items_center()
1395 .items_center()
1376 .child(toolbar_camera(app, model))
1396 .rounded_full()
1397 .bg(theme::surface_raised())
1398 .child(camera_button(app, model))
1377 .children(camera_menu_button(app, model, CameraMenu::of(state))),
1399 .children(camera_menu_button(app, model, CameraMenu::of(state))),
1378 )
1400 )
1379 .child(share_button(
1401 .child(share_button(
@@ -1381,18 +1403,34 @@ pub fn render_call_view(
1381 model,
1403 model,
1382 ShareOptions::of(state),
1404 ShareOptions::of(state),
1383 call.share_menu_open,
1405 call.share_menu_open,
1384 ));
1406 ))
1385 let controls = h_flex()
1407 .when(
1386 .debug_selector(|| "shell/islands/main/call-header/controls".into())
1408 model.has_reaction_controls() && !folded.folds(Foldable::RaiseHand),
1387 .flex_none()
1409 |row| row.child(hand_button(app, model)),
1388 .gap(px(GROUP_GAP))
1410 )
1389 .items_center()
1411 .when(
1390 .child(devices)
1412 model.has_reaction_controls() && !folded.folds(Foldable::Reactions),
1391 .child(group_divider())
1413 |row| row.child(reactions_button(app, model)),
1392 .child(panels_and_reactions)
1414 )
1393 .child(group_divider())
1415 .when(!folded.folds(Foldable::View), |row| {
1394 .child(stage_and_more);
1416 row.child(view_button(app, model, fullscreen))
1395 let header = header.child(title_group).child(controls).child(end_group);
1417 })
1418 .children(more_button(app, model, &folded))
1419 .when(
1420 model.kind != CallKind::Test && !folded.folds(Foldable::People),
1421 |row| row.child(people_button(app, call.people_open, model.raised_hands())),
1422 )
1423 .when(
1424 call.chat_thread().is_some() && !folded.folds(Foldable::Chat),
1425 |row| row.child(chat_button(app, call.chat_open, state.call_chat_unread())),
1426 )
1427 .child(
1428 leave_button(app, model, "call-leave", false)
1429 .debug_selector(|| "shell/islands/main/call-controls/leave".into()),
1430 )
1431 .when(has_leave_menu(model), |row| {
1432 row.child(leave_menu(app, model))
1433 });
1396
1434
1397 let top = v_flex()
1435 let top = v_flex()
1398 .w_full()
1436 .w_full()
@@ -1423,19 +1461,28 @@ pub fn render_call_view(
1423 column.child(fullscreen_chrome("call-chrome-top", app, top))
1461 column.child(fullscreen_chrome("call-chrome-top", app, top))
1424 })
1462 })
1425 .child(region)
1463 .child(region)
1464 .when(chrome_visible, |column| {
1465 column.child(fullscreen_chrome("call-chrome-bottom", app, controls))
1466 })
1426 } else {
1467 } else {
1427 base.rounded(px(10.))
1468 base.rounded(px(10.))
1428 .child(top.debug_selector(|| "shell/islands/main/call-header".into()))
1469 .child(top.debug_selector(|| "shell/islands/main/call-header".into()))
1429 .child(region)
1470 .child(region)
1471 .child(controls.debug_selector(|| "shell/islands/main/call-controls".into()))
1430 }
1472 }
1431 .children(captions_overlay(model, now))
1473 .children(captions_overlay(model, now))
1432 .children(captions_hint_chip(model))
1474 .children(captions_hint_chip(model))
1433 .children(push_to_talk_chip(call))
1475 .children(push_to_talk_chip(call))
1434 .children(state.transfer_picker.clone())
1476 .children(state.transfer_picker.clone())
1435 .children(options_dialog(app, call))
1477 .children(options_dialog(app, call))
1436 .children(consent_overlay(app, model));
1478 .children(consent_overlay(app, model))
1479 .children(local_share_float(app, state));
1480 let share_in_chat = call
1481 .chat_open
1482 .then(|| local_share_window(app, state, CHAT_PANEL_WIDTH))
1483 .flatten();
1437 let panels: Vec<AnyElement> = chat
1484 let panels: Vec<AnyElement> = chat
1438 .map(|chat| chat_panel(app, chat))
1485 .map(|chat| chat_panel(app, share_in_chat, chat))
1439 .into_iter()
1486 .into_iter()
1440 .chain(
1487 .chain(
1441 call.transcript_open
1488 call.transcript_open
@@ -1469,17 +1516,15 @@ fn side_panels(panels: Vec<AnyElement>, island_width: f32) -> Vec<AnyElement> {
1469 if island_width - panels_width >= OVERLAY_BELOW {
1516 if island_width - panels_width >= OVERLAY_BELOW {
1470 return panels;
1517 return panels;
1471 }
1518 }
1472 vec![
1519 vec![h_flex()
1473 h_flex()
1520 .absolute()
1474 .absolute()
1521 .top_0()
1475 .top(px(HEADER_HEIGHT))
1522 .right_0()
1476 .right_0()
1523 .bottom(px(CONTROLS_HEIGHT))
1477 .bottom_0()
1524 .gap(px(ISLAND_GAP))
1478 .gap(px(ISLAND_GAP))
1525 .w(px(panels_width.min(island_width)))
1479 .w(px(panels_width.min(island_width)))
1526 .children(panels)
1480 .children(panels)
1527 .into_any_element()]
1481 .into_any_element(),
1482 ]
1483}
1528}
1484
1529
1485fn fullscreen_chrome(id: &'static str, app: &Entity<AppState>, content: Div) -> Stateful<Div> {
1530fn fullscreen_chrome(id: &'static str, app: &Entity<AppState>, content: Div) -> Stateful<Div> {
@@ -1494,19 +1539,146 @@ fn fullscreen_chrome(id: &'static str, app: &Entity<AppState>, content: Div) ->
1494 .child(content)
1539 .child(content)
1495}
1540}
1496
1541
1497fn chat_panel(app: &Entity<AppState>, chat: AnyView) -> AnyElement {
1542fn chat_panel(app: &Entity<AppState>, share: Option<AnyElement>, chat: AnyView) -> AnyElement {
1498 let app = app.clone();
1543 let app = app.clone();
1544 let body = v_flex()
1545 .w_full()
1546 .flex_1()
1547 .min_h_0()
1548 .children(share)
1549 .child(div().flex_1().min_h_0().overflow_hidden().child(chat));
1499 side_panel(
1550 side_panel(
1500 "call-chat-panel",
1551 "call-chat-panel",
1501 "Chat",
1552 "Chat",
1502 "Close the chat",
1553 "Close the chat",
1503 move |cx| app.update(cx, |state, cx| state.toggle_call_chat(cx)),
1554 move |cx| app.update(cx, |state, cx| state.toggle_call_chat(cx)),
1504 chat,
1555 body,
1505 )
1556 )
1506 .debug_selector(|| CHAT_PANEL_TAG.into())
1557 .debug_selector(|| CHAT_PANEL_TAG.into())
1507 .into_any_element()
1558 .into_any_element()
1508}
1559}
1509
1560
1561const SHARE_WINDOW_INSET: f32 = 12.;
1562const SHARE_WINDOW_RATIO: f32 = 9. / 16.;
1563const SHARE_FLOAT_WIDTH: f32 = 320.;
1564
1565/// The live local share, pinned in the meeting chat or floating on the call
1566/// when the chat is closed.
1567fn local_share_window(app: &Entity<AppState>, state: &AppState, width: f32) -> Option<AnyElement> {
1568 let call = state.call.as_ref()?;
1569 let label = call.model.local_share.clone()?;
1570 let image = call.pictures.live(&VideoKey::LocalScreen, Instant::now());
1571 Some(share_window(app, &label, image, width))
1572}
1573
1574fn local_share_float(app: &Entity<AppState>, state: &AppState) -> Option<AnyElement> {
1575 let call = state.call.as_ref()?;
1576 if call.chat_open {
1577 return None;
1578 }
1579 let window = local_share_window(app, state, SHARE_FLOAT_WIDTH)?;
1580 Some(
1581 div()
1582 .absolute()
1583 .right(px(16.))
1584 .bottom(px(CONTROLS_HEIGHT + 12.))
1585 .w(px(SHARE_FLOAT_WIDTH))
1586 .rounded(px(10.))
1587 .overflow_hidden()
1588 .bg(theme::surface())
1589 .shadow(theme::flyout_shadow())
1590 .child(window)
1591 .into_any_element(),
1592 )
1593}
1594
1595fn share_window(
1596 app: &Entity<AppState>,
1597 label: &str,
1598 image: Option<Arc<RenderImage>>,
1599 width: f32,
1600) -> AnyElement {
1601 let picture_width = (width - 2. * SHARE_WINDOW_INSET).max(0.);
1602 let picture_height = picture_width * SHARE_WINDOW_RATIO;
1603 let stop = app.clone();
1604 v_flex()
1605 .w_full()
1606 .flex_none()
1607 .p(px(SHARE_WINDOW_INSET))
1608 .child(
1609 div()
1610 .id("call-share-window")
1611 .relative()
1612 .w(px(picture_width))
1613 .h(px(picture_height))
1614 .rounded(px(8.))
1615 .overflow_hidden()
1616 .bg(hsla(0., 0., 0.04, 1.))
1617 .child(share_picture(image))
1618 .child(
1619 div()
1620 .absolute()
1621 .top(px(8.))
1622 .left(px(8.))
1623 .max_w(px(picture_width * 0.62))
1624 .h(px(22.))
1625 .px(px(8.))
1626 .flex()
1627 .items_center()
1628 .rounded_full()
1629 .bg(hsla(0., 0., 0., 0.6))
1630 .text_size(px(11.))
1631 .text_color(theme::white())
1632 .child(div().truncate().child(label.to_owned())),
1633 )
1634 .child(share_stop(stop)),
1635 )
1636 .into_any_element()
1637}
1638
1639fn share_picture(image: Option<Arc<RenderImage>>) -> AnyElement {
1640 let Some(image) = image else {
1641 return div()
1642 .size_full()
1643 .flex()
1644 .items_center()
1645 .justify_center()
1646 .px(px(12.))
1647 .text_size(px(12.))
1648 .text_color(theme::text_muted())
1649 .child(WAITING_TEXT)
1650 .into_any_element();
1651 };
1652 img(ImageSource::Render(image))
1653 .size_full()
1654 .object_fit(ObjectFit::Contain)
1655 .into_any_element()
1656}
1657
1658fn share_stop(app: Entity<AppState>) -> Stateful<Div> {
1659 div()
1660 .id("call-share-window-stop")
1661 .absolute()
1662 .top(px(8.))
1663 .right(px(8.))
1664 .h(px(22.))
1665 .px(px(8.))
1666 .flex()
1667 .items_center()
1668 .rounded_full()
1669 .bg(theme::red())
1670 .text_color(theme::white())
1671 .text_size(px(11.))
1672 .font_weight(FontWeight::SEMIBOLD)
1673 .cursor_pointer()
1674 .hover(|button| button.opacity(0.85))
1675 .child("Stop")
1676 .on_click(move |_, _, cx| {
1677 cx.stop_propagation();
1678 app.update(cx, |state, cx| state.stop_call_share(cx));
1679 })
1680}
1681
1510pub fn side_panel(
1682pub fn side_panel(
1511 panel_id: &'static str,
1683 panel_id: &'static str,
1512 title: &'static str,
1684 title: &'static str,
@@ -1558,14 +1730,25 @@ pub fn side_panel(
1558
1730
1559#[cfg(test)]
1731#[cfg(test)]
1560mod tests {
1732mod tests {
1561 use super::{TileSize, name_plate_metrics};
1733 use super::{name_plate_metrics, TileSize};
1562
1734
1563 #[test]
1735 #[test]
1564 fn small_strip_tiles_get_a_compact_name_plate() {
1736 fn small_strip_tiles_get_a_compact_name_plate() {
1565 let strip = name_plate_metrics(TileSize { width: 216., height: 121.5, avatar: 48. });
1737 let strip = name_plate_metrics(TileSize {
1566 assert_eq!((strip.text_size, strip.inset, strip.padding_y), (11., 4., 2.));
1738 width: 216.,
1739 height: 121.5,
1740 avatar: 48.,
1741 });
1742 assert_eq!(
1743 (strip.text_size, strip.inset, strip.padding_y),
1744 (11., 4., 2.)
1745 );
1567 assert!(strip.max_width_share < 1.);
1746 assert!(strip.max_width_share < 1.);
1568 let stage = name_plate_metrics(TileSize { width: 640., height: 360., avatar: 96. });
1747 let stage = name_plate_metrics(TileSize {
1748 width: 640.,
1749 height: 360.,
1750 avatar: 96.,
1751 });
1569 assert_eq!((stage.text_size, stage.inset), (12., 8.));
1752 assert_eq!((stage.text_size, stage.inset), (12., 8.));
1570 }
1753 }
1571}
1754}