Add tooltip for following collaborators in titlebar

Max Brunsfeld created

Change summary

crates/collab_ui2/src/collab_titlebar_item.rs | 267 --------------------
1 file changed, 6 insertions(+), 261 deletions(-)

Detailed changes

crates/collab_ui2/src/collab_titlebar_item.rs 🔗

@@ -112,8 +112,6 @@ impl Render for CollabTitlebarItem {
                             ))
                             .children(
                                 remote_participants.iter().filter_map(|collaborator| {
-                                    // collaborator.is_
-
                                     let face_pile = self.render_collaborator(
                                         &collaborator.user,
                                         collaborator.peer_id,
@@ -143,6 +141,12 @@ impl Render for CollabTitlebarItem {
                                                         })
                                                         .ok();
                                                 })
+                                            })
+                                            .tooltip({
+                                                let login = collaborator.user.github_login.clone();
+                                                move |cx| {
+                                                    Tooltip::text(format!("Follow {login}"), cx)
+                                                }
                                             }),
                                     )
                                 }),
@@ -744,265 +748,6 @@ impl CollabTitlebarItem {
     //     .into_any()
     // }
 
-    // fn render_collaborators(
-    //     &self,
-    //     workspace: &ViewHandle<Workspace>,
-    //     theme: &Theme,
-    //     room: &ModelHandle<Room>,
-    //     cx: &mut ViewContext<Self>,
-    // ) -> Vec<Container<Self>> {
-    //     let mut participants = room
-    //         .read(cx)
-    //         .remote_participants()
-    //         .values()
-    //         .cloned()
-    //         .collect::<Vec<_>>();
-    //     participants.sort_by_cached_key(|p| p.user.github_login.clone());
-
-    //     participants
-    //         .into_iter()
-    //         .filter_map(|participant| {
-    //             let project = workspace.read(cx).project().read(cx);
-    //             let replica_id = project
-    //                 .collaborators()
-    //                 .get(&participant.peer_id)
-    //                 .map(|collaborator| collaborator.replica_id);
-    //             let user = participant.user.clone();
-    //             Some(
-    //                 Container::new(self.render_face_pile(
-    //                     &user,
-    //                     replica_id,
-    //                     participant.peer_id,
-    //                     Some(participant.location),
-    //                     participant.muted,
-    //                     participant.speaking,
-    //                     workspace,
-    //                     theme,
-    //                     cx,
-    //                 ))
-    //                 .with_margin_right(theme.titlebar.face_pile_spacing),
-    //             )
-    //         })
-    //         .collect()
-    // }
-
-    // fn render_current_user(
-    //     &self,
-    //     workspace: &ViewHandle<Workspace>,
-    //     theme: &Theme,
-    //     user: &Arc<User>,
-    //     peer_id: PeerId,
-    //     muted: bool,
-    //     speaking: bool,
-    //     cx: &mut ViewContext<Self>,
-    // ) -> AnyElement<Self> {
-    //     let replica_id = workspace.read(cx).project().read(cx).replica_id();
-
-    //     Container::new(self.render_face_pile(
-    //         user,
-    //         Some(replica_id),
-    //         peer_id,
-    //         None,
-    //         muted,
-    //         speaking,
-    //         workspace,
-    //         theme,
-    //         cx,
-    //     ))
-    //     .with_margin_right(theme.titlebar.item_spacing)
-    //     .into_any()
-    // }
-
-    // fn render_face_pile(
-    //     &self,
-    //     user: &User,
-    //     _replica_id: Option<ReplicaId>,
-    //     peer_id: PeerId,
-    //     location: Option<ParticipantLocation>,
-    //     muted: bool,
-    //     speaking: bool,
-    //     workspace: &ViewHandle<Workspace>,
-    //     theme: &Theme,
-    //     cx: &mut ViewContext<Self>,
-    // ) -> AnyElement<Self> {
-    //     let user_id = user.id;
-    //     let project_id = workspace.read(cx).project().read(cx).remote_id();
-    //     let room = ActiveCall::global(cx).read(cx).room().cloned();
-    //     let self_peer_id = workspace.read(cx).client().peer_id();
-    //     let self_following = workspace.read(cx).is_being_followed(peer_id);
-    //     let self_following_initialized = self_following
-    //         && room.as_ref().map_or(false, |room| match project_id {
-    //             None => true,
-    //             Some(project_id) => room
-    //                 .read(cx)
-    //                 .followers_for(peer_id, project_id)
-    //                 .iter()
-    //                 .any(|&follower| Some(follower) == self_peer_id),
-    //         });
-
-    //     let leader_style = theme.titlebar.leader_avatar;
-    //     let follower_style = theme.titlebar.follower_avatar;
-
-    //     let microphone_state = if muted {
-    //         Some(theme.titlebar.muted)
-    //     } else if speaking {
-    //         Some(theme.titlebar.speaking)
-    //     } else {
-    //         None
-    //     };
-
-    //     let mut background_color = theme
-    //         .titlebar
-    //         .container
-    //         .background_color
-    //         .unwrap_or_default();
-
-    //     let participant_index = self
-    //         .user_store
-    //         .read(cx)
-    //         .participant_indices()
-    //         .get(&user_id)
-    //         .copied();
-    //     if let Some(participant_index) = participant_index {
-    //         if self_following_initialized {
-    //             let selection = theme
-    //                 .editor
-    //                 .selection_style_for_room_participant(participant_index.0)
-    //                 .selection;
-    //             background_color = Color::blend(selection, background_color);
-    //             background_color.a = 255;
-    //         }
-    //     }
-
-    //     enum TitlebarParticipant {}
-
-    //     let content = MouseEventHandler::new::<TitlebarParticipant, _>(
-    //         peer_id.as_u64() as usize,
-    //         cx,
-    //         move |_, cx| {
-    //             Stack::new()
-    //                 .with_children(user.avatar.as_ref().map(|avatar| {
-    //                     let face_pile = FacePile::new(theme.titlebar.follower_avatar_overlap)
-    //                         .with_child(Self::render_face(
-    //                             avatar.clone(),
-    //                             Self::location_style(workspace, location, leader_style, cx),
-    //                             background_color,
-    //                             microphone_state,
-    //                         ))
-    //                         .with_children(
-    //                             (|| {
-    //                                 let project_id = project_id?;
-    //                                 let room = room?.read(cx);
-    //                                 let followers = room.followers_for(peer_id, project_id);
-    //                                 Some(followers.into_iter().filter_map(|&follower| {
-    //                                     if Some(follower) == self_peer_id {
-    //                                         return None;
-    //                                     }
-    //                                     let participant =
-    //                                         room.remote_participant_for_peer_id(follower)?;
-    //                                     Some(Self::render_face(
-    //                                         participant.user.avatar.clone()?,
-    //                                         follower_style,
-    //                                         background_color,
-    //                                         None,
-    //                                     ))
-    //                                 }))
-    //                             })()
-    //                             .into_iter()
-    //                             .flatten(),
-    //                         )
-    //                         .with_children(
-    //                             self_following_initialized
-    //                                 .then(|| self.user_store.read(cx).current_user())
-    //                                 .and_then(|user| {
-    //                                     Some(Self::render_face(
-    //                                         user?.avatar.clone()?,
-    //                                         follower_style,
-    //                                         background_color,
-    //                                         None,
-    //                                     ))
-    //                                 }),
-    //                         );
-
-    //                     let mut container = face_pile
-    //                         .contained()
-    //                         .with_style(theme.titlebar.leader_selection);
-
-    //                     if let Some(participant_index) = participant_index {
-    //                         if self_following_initialized {
-    //                             let color = theme
-    //                                 .editor
-    //                                 .selection_style_for_room_participant(participant_index.0)
-    //                                 .selection;
-    //                             container = container.with_background_color(color);
-    //                         }
-    //                     }
-
-    //                     container
-    //                 }))
-    //                 .with_children((|| {
-    //                     let participant_index = participant_index?;
-    //                     let color = theme
-    //                         .editor
-    //                         .selection_style_for_room_participant(participant_index.0)
-    //                         .cursor;
-    //                     Some(
-    //                         AvatarRibbon::new(color)
-    //                             .constrained()
-    //                             .with_width(theme.titlebar.avatar_ribbon.width)
-    //                             .with_height(theme.titlebar.avatar_ribbon.height)
-    //                             .aligned()
-    //                             .bottom(),
-    //                     )
-    //                 })())
-    //         },
-    //     );
-
-    //     if Some(peer_id) == self_peer_id {
-    //         return content.into_any();
-    //     }
-
-    //     content
-    //         .with_cursor_style(CursorStyle::PointingHand)
-    //         .on_click(MouseButton::Left, move |_, this, cx| {
-    //             let Some(workspace) = this.workspace.upgrade(cx) else {
-    //                 return;
-    //             };
-    //             if let Some(task) =
-    //                 workspace.update(cx, |workspace, cx| workspace.follow(peer_id, cx))
-    //             {
-    //                 task.detach_and_log_err(cx);
-    //             }
-    //         })
-    //         .with_tooltip::<TitlebarParticipant>(
-    //             peer_id.as_u64() as usize,
-    //             format!("Follow {}", user.github_login),
-    //             Some(Box::new(FollowNextCollaborator)),
-    //             theme.tooltip.clone(),
-    //             cx,
-    //         )
-    //         .into_any()
-    // }
-
-    // fn location_style(
-    //     workspace: &ViewHandle<Workspace>,
-    //     location: Option<ParticipantLocation>,
-    //     mut style: AvatarStyle,
-    //     cx: &ViewContext<Self>,
-    // ) -> AvatarStyle {
-    //     if let Some(location) = location {
-    //         if let ParticipantLocation::SharedProject { project_id } = location {
-    //             if Some(project_id) != workspace.read(cx).project().read(cx).remote_id() {
-    //                 style.image.grayscale = true;
-    //             }
-    //         } else {
-    //             style.image.grayscale = true;
-    //         }
-    //     }
-
-    //     style
-    // }
-
     // fn render_connection_status(
     //     &self,
     //     status: &client::Status,