collab_ui.rs

  1pub mod channel_view;
  2pub mod chat_panel;
  3pub mod collab_panel;
  4mod collab_titlebar_item;
  5mod face_pile;
  6pub mod notification_panel;
  7pub mod notifications;
  8mod panel_settings;
  9
 10use std::sync::Arc;
 11
 12pub use collab_titlebar_item::CollabTitlebarItem;
 13use gpui::AppContext;
 14pub use panel_settings::{
 15    ChatPanelSettings, CollaborationPanelSettings, NotificationPanelSettings,
 16};
 17use settings::Settings;
 18use workspace::AppState;
 19
 20// actions!(
 21//     collab,
 22//     [ToggleScreenSharing, ToggleMute, ToggleDeafen, LeaveCall]
 23// );
 24
 25pub fn init(_app_state: &Arc<AppState>, cx: &mut AppContext) {
 26    CollaborationPanelSettings::register(cx);
 27    ChatPanelSettings::register(cx);
 28    NotificationPanelSettings::register(cx);
 29
 30    // vcs_menu::init(cx);
 31    collab_titlebar_item::init(cx);
 32    // collab_panel::init(cx);
 33    // chat_panel::init(cx);
 34    // notifications::init(&app_state, cx);
 35
 36    // cx.add_global_action(toggle_screen_sharing);
 37    // cx.add_global_action(toggle_mute);
 38    // cx.add_global_action(toggle_deafen);
 39}
 40
 41// pub fn toggle_screen_sharing(_: &ToggleScreenSharing, cx: &mut AppContext) {
 42//     let call = ActiveCall::global(cx).read(cx);
 43//     if let Some(room) = call.room().cloned() {
 44//         let client = call.client();
 45//         let toggle_screen_sharing = room.update(cx, |room, cx| {
 46//             if room.is_screen_sharing() {
 47//                 report_call_event_for_room(
 48//                     "disable screen share",
 49//                     room.id(),
 50//                     room.channel_id(),
 51//                     &client,
 52//                     cx,
 53//                 );
 54//                 Task::ready(room.unshare_screen(cx))
 55//             } else {
 56//                 report_call_event_for_room(
 57//                     "enable screen share",
 58//                     room.id(),
 59//                     room.channel_id(),
 60//                     &client,
 61//                     cx,
 62//                 );
 63//                 room.share_screen(cx)
 64//             }
 65//         });
 66//         toggle_screen_sharing.detach_and_log_err(cx);
 67//     }
 68// }
 69
 70// pub fn toggle_mute(_: &ToggleMute, cx: &mut AppContext) {
 71//     let call = ActiveCall::global(cx).read(cx);
 72//     if let Some(room) = call.room().cloned() {
 73//         let client = call.client();
 74//         room.update(cx, |room, cx| {
 75//             let operation = if room.is_muted(cx) {
 76//                 "enable microphone"
 77//             } else {
 78//                 "disable microphone"
 79//             };
 80//             report_call_event_for_room(operation, room.id(), room.channel_id(), &client, cx);
 81
 82//             room.toggle_mute(cx)
 83//         })
 84//         .map(|task| task.detach_and_log_err(cx))
 85//         .log_err();
 86//     }
 87// }
 88
 89// pub fn toggle_deafen(_: &ToggleDeafen, cx: &mut AppContext) {
 90//     if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() {
 91//         room.update(cx, Room::toggle_deafen)
 92//             .map(|task| task.detach_and_log_err(cx))
 93//             .log_err();
 94//     }
 95// }
 96
 97// fn notification_window_options(
 98//     screen: Rc<dyn Screen>,
 99//     window_size: Vector2F,
100// ) -> WindowOptions<'static> {
101//     const NOTIFICATION_PADDING: f32 = 16.;
102
103//     let screen_bounds = screen.content_bounds();
104//     WindowOptions {
105//         bounds: WindowBounds::Fixed(RectF::new(
106//             screen_bounds.upper_right()
107//                 + vec2f(
108//                     -NOTIFICATION_PADDING - window_size.x(),
109//                     NOTIFICATION_PADDING,
110//                 ),
111//             window_size,
112//         )),
113//         titlebar: None,
114//         center: false,
115//         focus: false,
116//         show: true,
117//         kind: WindowKind::PopUp,
118//         is_movable: false,
119//         screen: Some(screen),
120//     }
121// }
122
123// fn render_avatar<T: 'static>(
124//     avatar: Option<Arc<ImageData>>,
125//     avatar_style: &AvatarStyle,
126//     container: ContainerStyle,
127// ) -> AnyElement<T> {
128//     avatar
129//         .map(|avatar| {
130//             Image::from_data(avatar)
131//                 .with_style(avatar_style.image)
132//                 .aligned()
133//                 .contained()
134//                 .with_corner_radius(avatar_style.outer_corner_radius)
135//                 .constrained()
136//                 .with_width(avatar_style.outer_width)
137//                 .with_height(avatar_style.outer_width)
138//                 .into_any()
139//         })
140//         .unwrap_or_else(|| {
141//             Empty::new()
142//                 .constrained()
143//                 .with_width(avatar_style.outer_width)
144//                 .into_any()
145//         })
146//         .contained()
147//         .with_style(container)
148//         .into_any()
149// }
150
151// fn is_channels_feature_enabled(cx: &gpui::WindowContext<'_>) -> bool {
152//     cx.is_staff() || cx.has_flag::<ChannelsAlpha>()
153// }